summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-08-29 14:42:11 +0000
committerTiago Cunha <tcunha@gmx.com>2010-08-29 14:42:11 +0000
commit56040be3468e655256362c7d5b230b15236b9dd2 (patch)
treeac7667f2e41cc6d09c01dc58d084e715e3f3dd77
parente6bb3d69422d948373b10074b043a8ef0189b1de (diff)
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.
-rw-r--r--cmd-pipe-pane.c4
-rw-r--r--job.c4
-rw-r--r--server.c4
-rw-r--r--signal.c31
-rw-r--r--tmux.c6
-rw-r--r--tmux.h6
-rw-r--r--window.c4
7 files changed, 37 insertions, 22 deletions
diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c
index 2e25b2de..85ff2d69 100644
--- a/cmd-pipe-pane.c
+++ b/cmd-pipe-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-pipe-pane.c,v 1.13 2010-06-15 20:25:40 tcunha Exp $ */
+/* $Id: cmd-pipe-pane.c,v 1.14 2010-08-29 14:42:11 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -96,7 +96,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
case 0:
/* Child process. */
close(pipe_fd[0]);
- clear_signals();
+ clear_signals(1);
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
_exit(1);
diff --git a/job.c b/job.c
index ff725010..63856a16 100644
--- a/job.c
+++ b/job.c
@@ -1,4 +1,4 @@
-/* $Id: job.c,v 1.17 2010-05-14 14:30:01 tcunha Exp $ */
+/* $Id: job.c,v 1.18 2010-08-29 14:42:11 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -148,7 +148,7 @@ job_run(struct job *job)
case -1:
return (-1);
case 0: /* child */
- clear_signals();
+ clear_signals(1);
environ_push(&global_environ);
diff --git a/server.c b/server.c
index 94bea25d..6d89fd01 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.242 2010-06-22 23:21:39 tcunha Exp $ */
+/* $Id: server.c,v 1.243 2010-08-29 14:42:11 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -143,7 +143,7 @@ server_start(char *path)
/* event_init() was called in our parent, need to reinit. */
if (event_reinit(ev_base) != 0)
fatal("event_reinit failed");
- clear_signals();
+ clear_signals(0);
logfile("server");
log_debug("server started, pid %ld", (long) getpid());
diff --git a/signal.c b/signal.c
index 602c7bb2..60736363 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 <nicm@users.sourceforge.net>
@@ -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);
+ }
}
diff --git a/tmux.c b/tmux.c
index b2a6d1b8..412e913e 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.214 2010-07-17 14:36:41 tcunha Exp $ */
+/* $Id: tmux.c,v 1.215 2010-08-29 14:42:11 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -566,7 +566,7 @@ main(int argc, char **argv)
event_dispatch();
- clear_signals();
+ clear_signals(0);
client_main(); /* doesn't return */
}
@@ -653,7 +653,7 @@ main_dispatch(const char *shellcmd)
memcpy(&shelldata, imsg.data, sizeof shelldata);
shelldata.shell[(sizeof shelldata.shell) - 1] = '\0';
- clear_signals();
+ clear_signals(0);
shell_exec(shelldata.shell, shellcmd);
default:
diff --git a/tmux.h b/tmux.h
index 6e8028b6..32dc897e 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.573 2010-08-11 22:16:03 tcunha Exp $ */
+/* $Id: tmux.h,v 1.574 2010-08-29 14:42:11 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1951,8 +1951,8 @@ void queue_window_name(struct window *);
char *default_window_name(struct window *);
/* signal.c */
-void set_signals(void(*handler)(int, short, unused void *));
-void clear_signals(void);
+void set_signals(void(*)(int, short, void *));
+void clear_signals(int);
/* session.c */
extern struct sessions sessions;
diff --git a/window.c b/window.c
index d7f55a1a..b532af5d 100644
--- a/window.c
+++ b/window.c
@@ -1,4 +1,4 @@
-/* $Id: window.c,v 1.134 2010-07-17 14:38:13 tcunha Exp $ */
+/* $Id: window.c,v 1.135 2010-08-29 14:42:11 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -572,7 +572,7 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
environ_push(env);
- clear_signals();
+ clear_signals(1);
log_close();
if (*wp->cmd != '\0') {