r23349: Fix from Steve Langasek <vorlon@debian.org> to
authorJeremy Allison <jra@samba.org>
Tue, 5 Jun 2007 01:59:37 +0000 (01:59 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:23:08 +0000 (12:23 -0500)
allow SIGTERM to cause nmbd to exit on awaiting
an interface to come up. Debian bug #168079
Jeremy.

source/nmbd/nmbd_subnetdb.c

index 4b04751235d8dda94c37a643b604ecf04f8b0c04..398119cc829daf2fcf080a0a7490a20f89f32e12 100644 (file)
@@ -185,12 +185,28 @@ BOOL create_subnets(void)
        struct in_addr unicast_ip, ipzero;
 
        if(num_interfaces == 0) {
+               void (*saved_handler)(int);
+
                DEBUG(0,("create_subnets: No local interfaces !\n"));
                DEBUG(0,("create_subnets: Waiting for an interface to appear ...\n"));
+
+               /* 
+                * Whilst we're waiting for an interface, allow SIGTERM to
+                * cause us to exit.
+                */
+
+               saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
+
                while (iface_count() == 0) {
                        sleep(5);
                        load_interfaces();
                }
+
+               /* 
+                * We got an interface, restore our normal term handler.
+                */
+
+               CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
        }
 
        num_interfaces = iface_count();