mirror of
https://github.com/tmux/tmux.git
synced 2025-04-22 20:38:48 +00:00
Sync OpenBSD patchset 698:
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@
This commit is contained in:
parent
9900e28ba8
commit
6694a01861
7
client.c
7
client.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.91 2010-05-14 14:30:00 tcunha Exp $ */
|
/* $Id: client.c,v 1.92 2010-05-14 14:35:26 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -210,6 +210,11 @@ client_signal(int sig, unused short events, unused void *data)
|
|||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
|
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
|
case SIGHUP:
|
||||||
|
client_exitmsg = "lost tty";
|
||||||
|
client_exitval = 1;
|
||||||
|
client_write_server(MSG_EXITING, NULL, 0);
|
||||||
|
break;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
client_exitmsg = "terminated";
|
client_exitmsg = "terminated";
|
||||||
client_exitval = 1;
|
client_exitval = 1;
|
||||||
|
10
signal.c
10
signal.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: signal.c,v 1.1 2010-05-14 14:30:01 tcunha Exp $ */
|
/* $Id: signal.c,v 1.2 2010-05-14 14:35:26 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
|
struct event ev_sighup;
|
||||||
struct event ev_sigchld;
|
struct event ev_sigchld;
|
||||||
struct event ev_sigcont;
|
struct event ev_sigcont;
|
||||||
struct event ev_sigterm;
|
struct event ev_sigterm;
|
||||||
@ -45,9 +46,9 @@ set_signals(void(*handler)(int, short, unused void *))
|
|||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
||||||
fatal("sigaction failed");
|
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_set(&ev_sigchld, SIGCHLD, handler, NULL);
|
||||||
signal_add(&ev_sigchld, NULL);
|
signal_add(&ev_sigchld, NULL);
|
||||||
signal_set(&ev_sigcont, SIGCONT, handler, NULL);
|
signal_set(&ev_sigcont, SIGCONT, handler, NULL);
|
||||||
@ -77,9 +78,8 @@ clear_signals(void)
|
|||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
if (sigaction(SIGHUP, &sigact, NULL) != 0)
|
|
||||||
fatal("sigaction failed");
|
|
||||||
|
|
||||||
|
event_del(&ev_sighup);
|
||||||
event_del(&ev_sigchld);
|
event_del(&ev_sigchld);
|
||||||
event_del(&ev_sigcont);
|
event_del(&ev_sigcont);
|
||||||
event_del(&ev_sigterm);
|
event_del(&ev_sigterm);
|
||||||
|
Loading…
Reference in New Issue
Block a user