diff options
author | Joel Sing <jsing@openbsd.org> | 2010-05-12 15:05:39 +0000 |
---|---|---|
committer | Joel Sing <jsing@openbsd.org> | 2010-05-12 15:05:39 +0000 |
commit | 72d1afa169505710f3c8a05d4c6f6fc12257bfc7 (patch) | |
tree | 7b7e2fd21b42d32fce896524106697799cd9e196 | |
parent | e0f4697e7cfd1a09d6332eae607fd3a9a1181234 (diff) |
Catch SIGHUP and terminate if running as a client. This prevents clients
from being left hanging around when, for example, a SSH session is
disconnected.
ok nicm@
-rw-r--r-- | client.c | 5 | ||||
-rw-r--r-- | signal.c | 8 |
2 files changed, 9 insertions, 4 deletions
@@ -206,6 +206,11 @@ client_signal(int sig, unused short events, unused void *data) struct sigaction sigact; switch (sig) { + case SIGHUP: + client_exitmsg = "lost tty"; + client_exitval = 1; + client_write_server(MSG_EXITING, NULL, 0); + break; case SIGTERM: client_exitmsg = "terminated"; client_exitval = 1; @@ -22,6 +22,7 @@ #include "tmux.h" +struct event ev_sighup; struct event ev_sigchld; struct event ev_sigcont; struct event ev_sigterm; @@ -45,9 +46,9 @@ set_signals(void(*handler)(int, short, unused void *)) fatal("sigaction failed"); if (sigaction(SIGTSTP, &sigact, NULL) != 0) fatal("sigaction failed"); - if (sigaction(SIGHUP, &sigact, NULL) != 0) - fatal("sigaction failed"); + signal_set(&ev_sighup, SIGHUP, handler, NULL); + signal_add(&ev_sighup, NULL); signal_set(&ev_sigchld, SIGCHLD, handler, NULL); signal_add(&ev_sigchld, NULL); signal_set(&ev_sigcont, SIGCONT, handler, NULL); @@ -77,9 +78,8 @@ clear_signals(void) fatal("sigaction failed"); if (sigaction(SIGTSTP, &sigact, NULL) != 0) fatal("sigaction failed"); - if (sigaction(SIGHUP, &sigact, NULL) != 0) - fatal("sigaction failed"); + event_del(&ev_sighup); event_del(&ev_sigchld); event_del(&ev_sigcont); event_del(&ev_sigterm); |