diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-11-28 20:09:48 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-11-28 20:09:48 +0000 |
commit | 804c80c6ad3756e0c37c1500843df619a3143c40 (patch) | |
tree | 83e85050068c003a73b63cc2a9c1b4a9a4817607 | |
parent | e6ca3a76cbe8979846f2c6b4b5ad3e58406a3989 (diff) |
slave_pid -1 by default, not 0, and reset to -1 when it goes away, with theo
-rw-r--r-- | libexec/ftpd/monitor.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libexec/ftpd/monitor.c b/libexec/ftpd/monitor.c index d0c06b4b3cb..ef4157238e4 100644 --- a/libexec/ftpd/monitor.c +++ b/libexec/ftpd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.2 2004/11/28 19:12:31 henning Exp $ */ +/* $OpenBSD: monitor.c,v 1.3 2004/11/28 20:09:47 henning Exp $ */ /* * Copyright (c) 2004 Moritz Jodeit <moritz@jodeit.org> @@ -58,7 +58,7 @@ extern void set_slave_signals(void); int fd_monitor = -1; int fd_slave = -1; int nullfd; -pid_t slave_pid; +pid_t slave_pid = -1; enum monitor_state state = PREAUTH; volatile sig_atomic_t quit = 0; @@ -380,7 +380,7 @@ sig_pass_to_slave(int signo) { int olderrno = errno; - if (slave_pid != 0) + if (slave_pid > 0) kill(slave_pid, signo); errno = olderrno; @@ -397,8 +397,10 @@ sig_chld(int signo) pid = waitpid(-1, &stat, WNOHANG); } while (pid == -1 && errno == EINTR); - if (pid == slave_pid && stat != PREAUTH_SLAVE_DIED) + if (pid == slave_pid && stat != PREAUTH_SLAVE_DIED) { quit = 1; + slave_pid = -1; + } errno = olderrno; } @@ -406,7 +408,7 @@ sig_chld(int signo) void kill_slave(void) { - if (slave_pid != 0) + if (slave_pid > 0) kill(slave_pid, SIGQUIT); } |