mirror of
https://github.com/tmux/tmux.git
synced 2025-09-05 08:07:03 +00:00
Sync OpenBSD patchset 374:
Rather than running status-left, status-right and window title #() with popen immediately every redraw, queue them up and run them in the background, starting each once every status-interval. The actual status line uses the output from the last run. This brings several advantages: - tmux itself may be called from inside #() without causing the server to hang; - likewise, sleep or similar doesn't cause the server to block; - commands aren't run excessively often when redrawing; - commands shared by status-left and status-right, or used multiple times, will only be run once. run-shell and if-shell still use system()/popen() but will be changed over to use this too later.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $Id: buffer-poll.c,v 1.16 2009-08-19 09:28:10 nicm Exp $ */
|
||||
/* $Id: buffer-poll.c,v 1.17 2009-10-11 23:55:26 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -29,9 +29,9 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
||||
{
|
||||
ssize_t n;
|
||||
|
||||
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
|
||||
if (pfd->revents & (POLLERR|POLLNVAL))
|
||||
return (-1);
|
||||
if (pfd->revents & POLLIN) {
|
||||
if (in != NULL && pfd->revents & POLLIN) {
|
||||
buffer_ensure(in, BUFSIZ);
|
||||
n = read(pfd->fd, BUFFER_IN(in), BUFFER_FREE(in));
|
||||
if (n == 0)
|
||||
@ -41,8 +41,9 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
||||
return (-1);
|
||||
} else
|
||||
buffer_add(in, n);
|
||||
}
|
||||
if (BUFFER_USED(out) > 0 && pfd->revents & POLLOUT) {
|
||||
} else if (pfd->revents & POLLHUP)
|
||||
return (-1);
|
||||
if (out != NULL && BUFFER_USED(out) > 0 && pfd->revents & POLLOUT) {
|
||||
n = write(pfd->fd, BUFFER_OUT(out), BUFFER_USED(out));
|
||||
if (n == -1) {
|
||||
if (errno != EINTR && errno != EAGAIN)
|
||||
|
Reference in New Issue
Block a user