@@ -116,6 +116,7 @@ const char* TEMP_DIR = "/tmp";
116
116
117
117
static void set_signal (int , void (*)(int ));
118
118
static void signal_handler (int );
119
+ static void shutdown_handler (int );
119
120
120
121
static TEXT protocol[128 ];
121
122
static int INET_SERVER_start = 0 ;
@@ -312,6 +313,13 @@ int CLIB_ROUTINE main( int argc, char** argv)
312
313
// activate paths set with -e family of switches
313
314
ISC_set_prefix (0 , 0 );
314
315
316
+ // set shutdown signals handler for listener
317
+ if (standaloneClassic)
318
+ {
319
+ set_signal (SIGTERM, shutdown_handler);
320
+ set_signal (SIGINT, shutdown_handler);
321
+ }
322
+
315
323
// ignore some signals
316
324
set_signal (SIGPIPE, signal_handler);
317
325
set_signal (SIGUSR1, signal_handler);
@@ -502,6 +510,13 @@ int CLIB_ROUTINE main( int argc, char** argv)
502
510
}
503
511
}
504
512
513
+ // set default handlers for child processes
514
+ if (standaloneClassic)
515
+ {
516
+ signal (SIGTERM, SIG_DFL);
517
+ signal (SIGINT, SIG_DFL);
518
+ }
519
+
505
520
if (classic)
506
521
{
507
522
port = INET_server (channel);
@@ -626,6 +641,23 @@ static void signal_handler(int)
626
641
++INET_SERVER_start;
627
642
}
628
643
644
+ static void shutdown_handler (int )
645
+ {
646
+ /* *************************************
647
+ *
648
+ * s h u t d o w n _ h a n d l e r
649
+ *
650
+ **************************************
651
+ *
652
+ * Functional description
653
+ * Forward sigterm signal to all child processes.
654
+ *
655
+ **************************************/
656
+
657
+ kill (-1 * getpid (), SIGTERM);
658
+
659
+ exit (FINI_OK);
660
+ }
629
661
630
662
#ifdef FB_RAISE_LIMITS
631
663
static void raiseLimit (int resource)
0 commit comments