summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-10-11 10:04:28 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-10-11 10:04:28 +0000
commitc7964be422d4499e887e9ad8540ee7187b27f1f6 (patch)
tree0da41d52352fc467485f5ce439d9cc385be327d7 /usr.bin/tmux/server.c
parent8a3e3e2520cb0b0b448c05fbfd1d8e11ea2d492e (diff)
Add a pipe-pane command to allow a pane to be piped to a shell command, for
example: pipe-pane 'cat >~/out' No arguments stops outputing and closes the pipe; the -o flag toggles a pipe and on and off (useful for key bindings). Suggested by espie@.
Diffstat (limited to 'usr.bin/tmux/server.c')
-rw-r--r--usr.bin/tmux/server.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index b57cf4afd7d..094ce14388f 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.54 2009/10/11 08:58:05 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.55 2009/10/11 10:04:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -572,6 +572,13 @@ server_fill_windows(void)
if (BUFFER_USED(wp->out) > 0)
events |= POLLOUT;
server_poll_add(wp->fd, events);
+
+ if (wp->pipe_fd == -1)
+ continue;
+ events = 0;
+ if (BUFFER_USED(wp->pipe_buf) > 0)
+ events |= POLLOUT;
+ server_poll_add(wp->pipe_fd, events);
}
}
}
@@ -600,6 +607,16 @@ server_handle_windows(void)
wp->fd = -1;
} else
server_handle_window(w, wp);
+
+ if (wp->pipe_fd == -1)
+ continue;
+ if ((pfd = server_poll_lookup(wp->pipe_fd)) == NULL)
+ continue;
+ if (buffer_poll(pfd, NULL, wp->pipe_buf) != 0) {
+ buffer_destroy(wp->pipe_buf);
+ close(wp->pipe_fd);
+ wp->pipe_fd = -1;
+ }
}
server_check_window(w);