summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/format.c13
-rw-r--r--usr.bin/tmux/server-fn.c32
-rw-r--r--usr.bin/tmux/server.c3
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/window.c3
5 files changed, 39 insertions, 16 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index 25c56261d2c..9ccb7ed9ffa 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.146 2017/08/09 11:43:45 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.147 2017/10/12 11:32:27 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1376,8 +1376,8 @@ void
format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
{
struct grid *gd = wp->base.grid;
+ int status = wp->status;
u_int idx;
- int status;
if (ft->w == NULL)
ft->w = wp->window;
@@ -1399,8 +1399,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
format_add(ft, "pane_input_off", "%d", !!(wp->flags & PANE_INPUTOFF));
format_add(ft, "pane_pipe", "%d", wp->pipe_fd != -1);
- status = wp->status;
- if (wp->fd == -1 && WIFEXITED(status))
+ if ((wp->flags & PANE_STATUSREADY) && WIFEXITED(status))
format_add(ft, "pane_dead_status", "%d", WEXITSTATUS(status));
format_add(ft, "pane_dead", "%d", wp->fd == -1);
@@ -1411,8 +1410,10 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
format_add(ft, "pane_bottom", "%u", wp->yoff + wp->sy - 1);
format_add(ft, "pane_at_left", "%d", wp->xoff == 0);
format_add(ft, "pane_at_top", "%d", wp->yoff == 0);
- format_add(ft, "pane_at_right", "%d", wp->xoff + wp->sx == wp->window->sx);
- format_add(ft, "pane_at_bottom", "%d", wp->yoff + wp->sy == wp->window->sy);
+ format_add(ft, "pane_at_right", "%d",
+ wp->xoff + wp->sx == wp->window->sx);
+ format_add(ft, "pane_at_bottom", "%d",
+ wp->yoff + wp->sy == wp->window->sy);
}
format_add(ft, "pane_in_mode", "%d", wp->screen != &wp->base);
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index 413bae44de9..b20654545d6 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.111 2017/08/29 09:18:48 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.112 2017/10/12 11:32:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -18,6 +18,7 @@
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/wait.h>
#include <sys/uio.h>
#include <imsg.h>
@@ -278,11 +279,11 @@ void
server_destroy_pane(struct window_pane *wp, int notify)
{
struct window *w = wp->window;
- int old_fd;
struct screen_write_ctx ctx;
struct grid_cell gc;
+ time_t t;
+ char tim[26];
- old_fd = wp->fd;
if (wp->fd != -1) {
bufferevent_free(wp->event);
close(wp->fd);
@@ -290,9 +291,13 @@ server_destroy_pane(struct window_pane *wp, int notify)
}
if (options_get_number(w->options, "remain-on-exit")) {
- if (old_fd == -1)
+ if (~wp->flags & PANE_STATUSREADY)
return;
+ if (wp->flags & PANE_STATUSDRAWN)
+ return;
+ wp->flags |= PANE_STATUSDRAWN;
+
if (notify)
notify_pane("pane-died", wp);
@@ -301,11 +306,24 @@ server_destroy_pane(struct window_pane *wp, int notify)
screen_write_cursormove(&ctx, 0, screen_size_y(ctx.s) - 1);
screen_write_linefeed(&ctx, 1, 8);
memcpy(&gc, &grid_default_cell, sizeof gc);
- gc.attr |= GRID_ATTR_BRIGHT;
- screen_write_puts(&ctx, &gc, "Pane is dead");
+
+ time(&t);
+ ctime_r(&t, tim);
+
+ if (WIFEXITED(wp->status)) {
+ screen_write_nputs(&ctx, -1, &gc,
+ "Pane is dead (status %d, %s)",
+ WEXITSTATUS(wp->status),
+ tim);
+ } else if (WIFSIGNALED(wp->status)) {
+ screen_write_nputs(&ctx, -1, &gc,
+ "Pane is dead (signal %d, %s)",
+ WTERMSIG(wp->status),
+ tim);
+ }
+
screen_write_stop(&ctx);
wp->flags |= PANE_REDRAW;
-
return;
}
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index 6ee356ffa6e..4bbb1878c8c 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.176 2017/07/14 18:49:07 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.177 2017/10/12 11:32:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -424,6 +424,7 @@ server_child_exited(pid_t pid, int status)
TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp->pid == pid) {
wp->status = status;
+ wp->flags |= PANE_STATUSREADY;
log_debug("%%%u exited", wp->id);
wp->flags |= PANE_EXITED;
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index d35363c171d..9feda04c683 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.805 2017/10/05 13:29:18 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.806 2017/10/12 11:32:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -778,6 +778,8 @@ struct window_pane {
#define PANE_INPUTOFF 0x40
#define PANE_CHANGED 0x80
#define PANE_EXITED 0x100
+#define PANE_STATUSREADY 0x200
+#define PANE_STATUSDRAWN 0x400
int argc;
char **argv;
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 37e163a3b9a..b5023cb98a2 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.205 2017/08/28 12:36:38 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.206 2017/10/12 11:32:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -908,6 +908,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
free((void *)wp->cwd);
wp->cwd = xstrdup(cwd);
}
+ wp->flags &= ~(PANE_STATUSREADY|PANE_STATUSDRAWN);
cmd = cmd_stringify_argv(wp->argc, wp->argv);
log_debug("spawn: %s -- %s", wp->shell, cmd);