@@ -115,6 +115,7 @@ const char* TEMP_DIR = "/tmp";
115
115
116
116
static void set_signal (int , void (*)(int ));
117
117
static void signal_handler (int );
118
+ static void shutdown_handler (int );
118
119
119
120
static TEXT protocol[128 ];
120
121
static int INET_SERVER_start = 0 ;
@@ -314,6 +315,13 @@ int CLIB_ROUTINE main( int argc, char** argv)
314
315
// activate paths set with -e family of switches
315
316
ISC_set_prefix (0 , 0 );
316
317
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
+
317
325
// ignore some signals
318
326
set_signal (SIGPIPE, signal_handler);
319
327
set_signal (SIGUSR1, signal_handler);
@@ -507,6 +515,13 @@ int CLIB_ROUTINE main( int argc, char** argv)
507
515
}
508
516
}
509
517
518
+ // set default handlers for child processes
519
+ if (standaloneClassic)
520
+ {
521
+ signal (SIGTERM, SIG_DFL);
522
+ signal (SIGINT, SIG_DFL);
523
+ }
524
+
510
525
if (classic)
511
526
{
512
527
port = INET_server (channel);
@@ -631,6 +646,23 @@ static void signal_handler(int)
631
646
++INET_SERVER_start;
632
647
}
633
648
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
+ }
634
666
635
667
#ifdef FB_RAISE_LIMITS
636
668
static void raiseLimit (int resource)
0 commit comments