diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-11-29 22:24:58 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-11-29 22:24:58 +0000 |
commit | f485a9db639f9d57b74971e2bcec8204339c69d0 (patch) | |
tree | bb1a336400dee6af9559b0cf1b5c4208676f9da4 /libexec/ftpd | |
parent | b5bb7ac498f4a1b68bc1e27d4729519fff179230 (diff) |
fix nasty signal races by blocking signals in signal handlers.
with moritz jodeit and theo, ok theo
Diffstat (limited to 'libexec/ftpd')
-rw-r--r-- | libexec/ftpd/monitor.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libexec/ftpd/monitor.c b/libexec/ftpd/monitor.c index ef4157238e4..ff9692ddf2a 100644 --- a/libexec/ftpd/monitor.c +++ b/libexec/ftpd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.3 2004/11/28 20:09:47 henning Exp $ */ +/* $OpenBSD: monitor.c,v 1.4 2004/11/29 22:24:57 henning Exp $ */ /* * Copyright (c) 2004 Moritz Jodeit <moritz@jodeit.org> @@ -378,11 +378,16 @@ handle_cmds(void) void sig_pass_to_slave(int signo) { + sigset_t allsigs, oldsigs; int olderrno = errno; + sigfillset(&allsigs); + sigprocmask(SIG_BLOCK, &allsigs, &oldsigs); + if (slave_pid > 0) kill(slave_pid, signo); + sigprocmask(SIG_SETMASK, &oldsigs, NULL); errno = olderrno; } @@ -391,8 +396,12 @@ void sig_chld(int signo) { pid_t pid; + sigset_t allsigs, oldsigs; int stat, olderrno = errno; + sigfillset(&allsigs); + sigprocmask(SIG_BLOCK, &allsigs, &oldsigs); + do { pid = waitpid(-1, &stat, WNOHANG); } while (pid == -1 && errno == EINTR); @@ -402,6 +411,7 @@ sig_chld(int signo) slave_pid = -1; } + sigprocmask(SIG_SETMASK, &oldsigs, NULL); errno = olderrno; } |