summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2018-11-30 08:44:41 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2018-11-30 08:44:41 +0000
commit8afcda0c5604153d1c697caea6dc247f65b42470 (patch)
treeed2284ccaaaa0808ed84183e9d9a351087f280dd
parenta886d8130b49576f526bac6f934e82dbf953882d (diff)
Clear PANE_EXITED flag when starting new child process in case the pane
has been respawned.
-rw-r--r--usr.bin/tmux/cmd-pipe-pane.c7
-rw-r--r--usr.bin/tmux/server-fn.c3
-rw-r--r--usr.bin/tmux/window.c6
3 files changed, 12 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-pipe-pane.c b/usr.bin/tmux/cmd-pipe-pane.c
index 95af043211b..34f5fa27ec5 100644
--- a/usr.bin/tmux/cmd-pipe-pane.c
+++ b/usr.bin/tmux/cmd-pipe-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-pipe-pane.c,v 1.48 2018/11/19 13:35:40 nicm Exp $ */
+/* $OpenBSD: cmd-pipe-pane.c,v 1.49 2018/11/30 08:44:40 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -158,7 +158,10 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
close(pipe_fd[1]);
wp->pipe_fd = pipe_fd[0];
- wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
+ if (wp->fd != -1)
+ wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
+ else
+ wp->pipe_off = 0;
setblocking(wp->pipe_fd, 0);
wp->pipe_event = bufferevent_new(wp->pipe_fd,
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index e7b86edc098..e66c265a504 100644
--- a/usr.bin/tmux/server-fn.c
+++ b/usr.bin/tmux/server-fn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-fn.c,v 1.117 2018/10/18 08:38:01 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.118 2018/11/30 08:44:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -302,6 +302,7 @@ server_destroy_pane(struct window_pane *wp, int notify)
if (wp->fd != -1) {
bufferevent_free(wp->event);
+ wp->event = NULL;
close(wp->fd);
wp->fd = -1;
}
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index a0ba831f299..eac84bdf3f9 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.214 2018/11/19 13:35:41 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.215 2018/11/30 08:44:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -921,6 +921,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
sigprocmask(SIG_BLOCK, &set, &oldset);
switch (wp->pid = fdforkpty(ptm_fd, &wp->fd, wp->tty, NULL, &ws)) {
case -1:
+ wp->event = NULL;
wp->fd = -1;
xasprintf(cause, "%s: %s", cmd, strerror(errno));
@@ -1000,6 +1001,9 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
if (wp->event == NULL)
fatalx("out of memory");
+ wp->pipe_off = 0;
+ wp->flags &= ~PANE_EXITED;
+
bufferevent_setwatermark(wp->event, EV_READ, 0, READ_SIZE);
bufferevent_enable(wp->event, EV_READ|EV_WRITE);