summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-07-12 10:04:52 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-07-12 10:04:52 +0000
commit535eb11fec1a0c5e06a96f69cb2fc284f482e932 (patch)
treebb6e66ddc8e7e6b6bac6effe303c4720e735d8f2 /usr.bin/tmux/server.c
parent4c10bb1e952802978efff50d3814cde68a5e5780 (diff)
Block signals between forking and clearing signal handlers (or calling
event_reinit) - if the child gets a signal and fires the libevent signal handler during this period it could write a signal into the parent's signal pipe. GitHub issue 1001 from Aaron van Geffen.
Diffstat (limited to 'usr.bin/tmux/server.c')
-rw-r--r--usr.bin/tmux/server.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index 2ca53f77839..fe565c18d28 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.174 2017/07/12 09:24:17 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.175 2017/07/12 10:04:51 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -141,21 +141,24 @@ server_start(struct tmuxproc *client, struct event_base *base, int lockfd,
{
int pair[2];
struct job *job;
+ sigset_t set, oldset;
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pair) != 0)
fatal("socketpair failed");
+ sigfillset(&set);
+ sigprocmask(SIG_BLOCK, &set, &oldset);
switch (fork()) {
case -1:
fatal("fork failed");
case 0:
break;
default:
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
close(pair[1]);
return (pair[0]);
}
close(pair[0]);
-
if (daemon(1, 0) != 0)
fatal("daemon failed");
proc_clear_signals(client);
@@ -163,6 +166,7 @@ server_start(struct tmuxproc *client, struct event_base *base, int lockfd,
fatalx("event_reinit failed");
server_proc = proc_start("server");
proc_set_signals(server_proc, server_signal);
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
if (log_get_level() > 1)
tty_create_log();