summaryrefslogtreecommitdiffstats
path: root/signal.c
diff options
context:
space:
mode:
authortcunha <tcunha>2010-08-29 14:42:11 +0000
committertcunha <tcunha>2010-08-29 14:42:11 +0000
commitc5542082b52d8897b2e5d6ddedb6d4d016413a04 (patch)
treea5e8c79488b519d3c7cbd10e46928cf906128926 /signal.c
parente47d20d7761cfd9525836a13272c690ec1b684ee (diff)
downloadtmux-old-c5542082b52d8897b2e5d6ddedb6d4d016413a04.tar.gz
tmux-old-c5542082b52d8897b2e5d6ddedb6d4d016413a04.tar.bz2
tmux-old-c5542082b52d8897b2e5d6ddedb6d4d016413a04.zip
Sync OpenBSD patchset 751:
Do not call event_del() for signals after fork(), just use sigaction() directly instead - calling libevent functions after fork() w/o event_reinit() is a bad idea, even if in this case it was harmless.
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/signal.c b/signal.c
index 8331375c..448f70b6 100644
--- a/signal.c
+++ b/signal.c
@@ -1,4 +1,4 @@
-/* $Id: signal.c,v 1.2 2010/05/14 14:35:26 tcunha Exp $ */
+/* $Id: signal.c,v 1.3 2010/08/29 14:42:11 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <[email protected]>
@@ -62,7 +62,7 @@ set_signals(void(*handler)(int, short, unused void *))
}
void
-clear_signals(void)
+clear_signals(int after_fork)
{
struct sigaction sigact;
@@ -79,10 +79,25 @@ clear_signals(void)
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
fatal("sigaction failed");
- event_del(&ev_sighup);
- event_del(&ev_sigchld);
- event_del(&ev_sigcont);
- event_del(&ev_sigterm);
- event_del(&ev_sigusr1);
- event_del(&ev_sigwinch);
+ if (after_fork) {
+ if (sigaction(SIGHUP, &sigact, NULL) != 0)
+ fatal("sigaction failed");
+ if (sigaction(SIGCHLD, &sigact, NULL) != 0)
+ fatal("sigaction failed");
+ if (sigaction(SIGCONT, &sigact, NULL) != 0)
+ fatal("sigaction failed");
+ if (sigaction(SIGTERM, &sigact, NULL) != 0)
+ fatal("sigaction failed");
+ if (sigaction(SIGUSR1, &sigact, NULL) != 0)
+ fatal("sigaction failed");
+ if (sigaction(SIGWINCH, &sigact, NULL) != 0)
+ fatal("sigaction failed");
+ } else {
+ event_del(&ev_sighup);
+ event_del(&ev_sigchld);
+ event_del(&ev_sigcont);
+ event_del(&ev_sigterm);
+ event_del(&ev_sigusr1);
+ event_del(&ev_sigwinch);
+ }
}