From c80f70390c3763d5d7248979db9542cd05b7cb44 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 15 Mar 2012 16:29:27 +0100 Subject: s3:smbd: let smbd/nmbd/winbindd child processes terminate if the parent process died. This applies to all child processes making use of reinit_after_fork(). It is implemented by establishing a pipe between parent and child. The child watches for EOF on the read end of the pipe, indidcating an exited parent. Pair-Programmed-With: Stefan Metzmacher --- source3/nmbd/nmbd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/nmbd') diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 52d7ed9e4e..eff1eca2f1 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -951,6 +951,17 @@ static bool open_sockets(bool isdaemon, int port) exit(1); } + /* + * Do not initialize the parent-child-pipe before becoming + * a daemon: this is used to detect a died parent in the child + * process. + */ + status = init_before_fork(); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("init_before_fork failed: %s\n", nt_errstr(status))); + exit(1); + } + if (!nmbd_setup_sig_term_handler(msg)) exit(1); if (!nmbd_setup_stdin_handler(msg, !Fork)) -- cgit