aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2017-07-14 18:49:07 +0000
committernicm <nicm>2017-07-14 18:49:07 +0000
commit932f6cfbfc98ab2d6e593f7fa3473a6bb3269967 (patch)
tree458fd646c28b3655f2ca1ca6a228188cc49ca2e0
parent2678fe53f57c4a3222780c76a7201f4300058e59 (diff)
downloadrtmux-932f6cfbfc98ab2d6e593f7fa3473a6bb3269967.tar.gz
rtmux-932f6cfbfc98ab2d6e593f7fa3473a6bb3269967.tar.bz2
rtmux-932f6cfbfc98ab2d6e593f7fa3473a6bb3269967.zip
Because ignore SIGCHLD early, letting signal_del restore it doesn't work
correctly, so set it explicitly back to default (and the others for good measure).
-rw-r--r--client.c4
-rw-r--r--cmd-pipe-pane.c2
-rw-r--r--job.c2
-rw-r--r--proc.c12
-rw-r--r--server.c2
-rw-r--r--tmux.h2
-rw-r--r--window.c2
7 files changed, 18 insertions, 8 deletions
diff --git a/client.c b/client.c
index efc82e5f..743ed33a 100644
--- a/client.c
+++ b/client.c
@@ -365,7 +365,6 @@ client_main(struct event_base *base, int argc, char **argv, int flags)
if (client_exittype == MSG_EXEC) {
if (client_flags & CLIENT_CONTROLCONTROL)
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
- proc_clear_signals(client_proc);
client_exec(client_execshell, client_execcmd);
}
@@ -481,6 +480,8 @@ client_exec(const char *shell, const char *shellcmd)
xasprintf(&argv0, "%s", name);
setenv("SHELL", shell, 1);
+ proc_clear_signals(client_proc, 1);
+
setblocking(STDIN_FILENO, 1);
setblocking(STDOUT_FILENO, 1);
setblocking(STDERR_FILENO, 1);
@@ -628,7 +629,6 @@ client_dispatch_wait(struct imsg *imsg)
if (datalen == 0 || data[datalen - 1] != '\0')
fatalx("bad MSG_SHELL string");
- proc_clear_signals(client_proc);
client_exec(data, shell_command);
/* NOTREACHED */
case MSG_DETACH:
diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c
index c2ec3ac3..8e8019e1 100644
--- a/cmd-pipe-pane.c
+++ b/cmd-pipe-pane.c
@@ -115,7 +115,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
case 0:
/* Child process. */
- proc_clear_signals(server_proc);
+ proc_clear_signals(server_proc, 1);
sigprocmask(SIG_SETMASK, &oldset, NULL);
close(pipe_fd[0]);
diff --git a/job.c b/job.c
index 9c6bba6e..866e36c7 100644
--- a/job.c
+++ b/job.c
@@ -72,7 +72,7 @@ job_run(const char *cmd, struct session *s, const char *cwd,
close(out[1]);
return (NULL);
case 0:
- proc_clear_signals(server_proc);
+ proc_clear_signals(server_proc, 1);
sigprocmask(SIG_SETMASK, &oldset, NULL);
if (cwd == NULL || chdir(cwd) != 0) {
diff --git a/proc.c b/proc.c
index 68738229..48e0d90c 100644
--- a/proc.c
+++ b/proc.c
@@ -242,7 +242,7 @@ proc_set_signals(struct tmuxproc *tp, void (*signalcb)(int))
}
void
-proc_clear_signals(struct tmuxproc *tp)
+proc_clear_signals(struct tmuxproc *tp, int defaults)
{
struct sigaction sa;
@@ -262,6 +262,16 @@ proc_clear_signals(struct tmuxproc *tp)
signal_del(&tp->ev_sigusr1);
signal_del(&tp->ev_sigusr2);
signal_del(&tp->ev_sigwinch);
+
+ if (defaults) {
+ sigaction(SIGHUP, &sa, NULL);
+ sigaction(SIGCHLD, &sa, NULL);
+ sigaction(SIGCONT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGUSR1, &sa, NULL);
+ sigaction(SIGUSR2, &sa, NULL);
+ sigaction(SIGWINCH, &sa, NULL);
+ }
}
struct tmuxpeer *
diff --git a/server.c b/server.c
index 3bb5f56b..753f6d01 100644
--- a/server.c
+++ b/server.c
@@ -161,7 +161,7 @@ server_start(struct tmuxproc *client, struct event_base *base, int lockfd,
close(pair[0]);
if (daemon(1, 0) != 0)
fatal("daemon failed");
- proc_clear_signals(client);
+ proc_clear_signals(client, 0);
if (event_reinit(base) != 0)
fatalx("event_reinit failed");
server_proc = proc_start("server");
diff --git a/tmux.h b/tmux.h
index 34a3572a..855a1dff 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1499,7 +1499,7 @@ struct tmuxproc *proc_start(const char *);
void proc_loop(struct tmuxproc *, int (*)(void));
void proc_exit(struct tmuxproc *);
void proc_set_signals(struct tmuxproc *, void(*)(int));
-void proc_clear_signals(struct tmuxproc *);
+void proc_clear_signals(struct tmuxproc *, int);
struct tmuxpeer *proc_add_peer(struct tmuxproc *, int,
void (*)(struct imsg *, void *), void *);
void proc_remove_peer(struct tmuxpeer *);
diff --git a/window.c b/window.c
index 08d2c6e5..f08e35ab 100644
--- a/window.c
+++ b/window.c
@@ -929,7 +929,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
sigprocmask(SIG_SETMASK, &oldset, NULL);
return (-1);
case 0:
- proc_clear_signals(server_proc);
+ proc_clear_signals(server_proc, 1);
sigprocmask(SIG_SETMASK, &oldset, NULL);
if (chdir(wp->cwd) != 0) {