@@ -115,6 +115,7 @@ const char* TEMP_DIR = "/tmp";
115115
116116static void set_signal (int , void (*)(int ));
117117static void signal_handler (int );
118+ static void shutdown_handler (int );
118119
119120static TEXT protocol[128 ];
120121static int INET_SERVER_start = 0 ;
@@ -314,6 +315,13 @@ int CLIB_ROUTINE main( int argc, char** argv)
314315 // activate paths set with -e family of switches
315316 ISC_set_prefix (0 , 0 );
316317
318+ // set shutdown signals handler for listener
319+ if (standaloneClassic)
320+ {
321+ set_signal (SIGTERM, shutdown_handler);
322+ set_signal (SIGINT, shutdown_handler);
323+ }
324+
317325 // ignore some signals
318326 set_signal (SIGPIPE, signal_handler);
319327 set_signal (SIGUSR1, signal_handler);
@@ -507,6 +515,13 @@ int CLIB_ROUTINE main( int argc, char** argv)
507515 }
508516 }
509517
518+ // set default handlers for child processes
519+ if (standaloneClassic)
520+ {
521+ signal (SIGTERM, SIG_DFL);
522+ signal (SIGINT, SIG_DFL);
523+ }
524+
510525 if (classic)
511526 {
512527 port = INET_server (channel);
@@ -631,6 +646,23 @@ static void signal_handler(int)
631646 ++INET_SERVER_start;
632647}
633648
649+ static void shutdown_handler (int )
650+ {
651+ /* *************************************
652+ *
653+ * s h u t d o w n _ h a n d l e r
654+ *
655+ **************************************
656+ *
657+ * Functional description
658+ * Forward sigterm signal to all child processes.
659+ *
660+ **************************************/
661+
662+ kill (-1 * getpid (), SIGTERM);
663+
664+ exit (FINI_OK);
665+ }
634666
635667#ifdef FB_RAISE_LIMITS
636668static void raiseLimit (int resource)
0 commit comments