diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-09-11 04:47:56 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:18:18 -0500 |
commit | f793748f4357f70668d8e8c2b90a88d2ff253566 (patch) | |
tree | 58a08f5d8ffa14fb22e8b940806894eac73d7ae8 /source4 | |
parent | cb487062c80c39eadfbedd97e86ae8339d036931 (diff) | |
download | samba-f793748f4357f70668d8e8c2b90a88d2ff253566.tar.gz samba-f793748f4357f70668d8e8c2b90a88d2ff253566.tar.bz2 samba-f793748f4357f70668d8e8c2b90a88d2ff253566.zip |
r18360: better handling of child process killing in standard mode
(This used to be commit 6a2144caab60073b40577dc1f66f663f817d6cbd)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/smbd/server.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source4/smbd/server.c b/source4/smbd/server.c index cb9ae51f08..cf0efc6522 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -103,6 +103,19 @@ static void sig_hup(int sig) debug_schedule_reopen_logs(); } +static void sig_term(int sig) +{ +#if HAVE_GETPGRP + static int done_sigterm; + if (done_sigterm == 0 && getpgrp() == getpid()) { + DEBUG(0,("SIGTERM: killing children\n")); + done_sigterm = 1; + kill(-getpgrp(), SIGTERM); + } +#endif + exit(0); +} + /* setup signal masks */ @@ -130,6 +143,7 @@ static void setup_signals(void) BlockSignals(False, SIGTERM); CatchSignal(SIGHUP, sig_hup); + CatchSignal(SIGTERM, sig_term); } /* @@ -142,6 +156,11 @@ static void server_stdin_handler(struct event_context *event_ctx, struct fd_even uint8_t c; if (read(0, &c, 1) == 0) { DEBUG(0,("%s: EOF on stdin - terminating\n", binary_name)); +#if HAVE_GETPGRP + if (getpgrp() == getpid()) { + kill(-getpgrp(), SIGTERM); + } +#endif exit(0); } } |