From: Stefan Metzmacher Date: Fri, 23 Jan 2009 09:13:29 +0000 (+0100) Subject: s3:nmbd: install the SIG_DFL handler for SIGTERM while we're waiting for interfaces X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=3aa3a8b6274a11cf27a2df4df97fe011b8b5aa76 s3:nmbd: install the SIG_DFL handler for SIGTERM while we're waiting for interfaces We should handle all 3 cases where we actively wait for interfaces in the same way. metze --- diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 0922e455a3ed..870b9a1f30d9 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -282,6 +282,7 @@ static void reload_interfaces(time_t t) /* We need to wait if there are no subnets... */ if (FIRST_SUBNET == NULL) { + void (*saved_handler)(int); if (print_waiting_msg) { DEBUG(0,("reload_interfaces: " @@ -293,29 +294,20 @@ static void reload_interfaces(time_t t) * Whilst we're waiting for an interface, allow SIGTERM to * cause us to exit. */ - - BlockSignals(false, SIGTERM); + saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL ); /* We only count IPv4, non-loopback interfaces here. */ - while (iface_count_v4_nl() == 0 && !got_sig_term) { + while (iface_count_v4_nl() == 0) { sleep(5); load_interfaces(); } - /* - * Handle termination inband. - */ - - if (got_sig_term) { - got_sig_term = 0; - terminate(); - } + CatchSignal( SIGTERM, SIGNAL_CAST saved_handler ); /* * We got an interface, go back to blocking term. */ - BlockSignals(true, SIGTERM); goto try_again; } }