@@ -72,6 +72,7 @@ static void sigtrap_handler(int code, siginfo_t *siginfo, void *context);
72
72
static void sigbus_handler (int code, siginfo_t *siginfo, void *context);
73
73
static void sigint_handler (int code, siginfo_t *siginfo, void *context);
74
74
static void sigquit_handler (int code, siginfo_t *siginfo, void *context);
75
+ static void sigterm_handler (int code, siginfo_t *siginfo, void *context);
75
76
76
77
static void common_signal_handler (int code, siginfo_t *siginfo, void *sigcontext, int numParams, ...);
77
78
@@ -91,7 +92,7 @@ struct sigaction g_previous_sigbus;
91
92
struct sigaction g_previous_sigsegv;
92
93
struct sigaction g_previous_sigint;
93
94
struct sigaction g_previous_sigquit;
94
-
95
+ struct sigaction g_previous_sigterm;
95
96
96
97
/* public function definitions ************************************************/
97
98
@@ -131,6 +132,7 @@ BOOL SEHInitializeSignals()
131
132
handle_signal (SIGSEGV, sigsegv_handler, &g_previous_sigsegv);
132
133
handle_signal (SIGINT, sigint_handler, &g_previous_sigint);
133
134
handle_signal (SIGQUIT, sigquit_handler, &g_previous_sigquit);
135
+ handle_signal (SIGTERM, sigterm_handler, &g_previous_sigterm);
134
136
135
137
#ifdef INJECT_ACTIVATION_SIGNAL
136
138
handle_signal (INJECT_ACTIVATION_SIGNAL, inject_activation_handler, NULL );
@@ -178,6 +180,7 @@ void SEHCleanupSignals()
178
180
restore_signal (SIGSEGV, &g_previous_sigsegv);
179
181
restore_signal (SIGINT, &g_previous_sigint);
180
182
restore_signal (SIGQUIT, &g_previous_sigquit);
183
+ restore_signal (SIGTERM, &g_previous_sigterm);
181
184
}
182
185
183
186
/* internal function definitions **********************************************/
@@ -384,6 +387,35 @@ static void sigquit_handler(int code, siginfo_t *siginfo, void *context)
384
387
kill (gPID , code);
385
388
}
386
389
390
+ /* ++
391
+ Function :
392
+ sigterm_handler
393
+
394
+ handle SIGTERM signal
395
+
396
+ Parameters :
397
+ POSIX signal handler parameter list ("man sigaction" for details)
398
+
399
+ (no return value)
400
+ --*/
401
+ static void sigterm_handler (int code, siginfo_t *siginfo, void *context)
402
+ {
403
+ if (PALIsInitialized ())
404
+ {
405
+ // g_pSynchronizationManager shouldn't be null if PAL is initialized.
406
+ _ASSERTE (g_pSynchronizationManager != nullptr );
407
+
408
+ g_pSynchronizationManager->SendTerminationRequestToWorkerThread ();
409
+ }
410
+ else
411
+ {
412
+ if (g_previous_sigterm.sa_sigaction != NULL )
413
+ {
414
+ g_previous_sigterm.sa_sigaction (code, siginfo, context);
415
+ }
416
+ }
417
+ }
418
+
387
419
#ifdef INJECT_ACTIVATION_SIGNAL
388
420
/* ++
389
421
Function :
0 commit comments