From 2a75aa630c1e53c1ce3e3d9bf4d306abfb3bb266 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 17 Sep 2020 14:00:10 -0700 Subject: [PATCH] SCP: Ignore subsequent SIGTERM receipt after initial receipt. The OS may signal SIGTERM more than once before ultimately issuing a SIGKILL. The initial SIGTERM will stop execution and initiate optional simulator cleanup. Ignoring follow up SIGTERMs will allow as much cleanup as possible to be achieved and thus allow the simulator to complete its cleanup and exit or ultimately exit die due to receipt of SIGKILL. Likewise for SIGHUP on hosts that can issue SIGHUP. --- scp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scp.c b/scp.c index 15898a40..af2c143a 100644 --- a/scp.c +++ b/scp.c @@ -8640,9 +8640,9 @@ sim_stop_timer_services (); /* disable wall clock ti sim_ttcmd (); /* restore console */ sim_brk_clrall (BRK_TYP_DYN_STEPOVER); /* cancel any step/over subroutine breakpoints */ #ifdef SIGHUP -signal (SIGHUP, SIG_DFL); /* cancel WRU */ +signal (SIGHUP, sigterm_received ? SIG_IGN : SIG_DFL); /* cancel WRU */ #endif -signal (SIGTERM, SIG_DFL); /* cancel WRU */ +signal (SIGTERM, sigterm_received ? SIG_IGN : SIG_DFL); /* cancel WRU */ sim_flush_buffered_files(); sim_cancel (&sim_flush_unit); /* cancel flush timer */ sim_cancel_step (); /* cancel step timer */