diff options
author | Björn-Egil Dahlberg <[email protected]> | 2017-04-04 15:35:50 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2017-04-04 15:35:50 +0200 |
commit | 38cd77b3e7afbf3973167c5a339381707e3d95bc (patch) | |
tree | de8a3dac88e62cd9ff2820ba7404bf21d1e08903 /erts/emulator/sys/unix/sys.c | |
parent | a748cafdc7063d9f181ba12088db6458793ced2f (diff) | |
parent | f92d862c1af230a873c2b2d30fea575ff3dafd56 (diff) | |
download | otp-38cd77b3e7afbf3973167c5a339381707e3d95bc.tar.gz otp-38cd77b3e7afbf3973167c5a339381707e3d95bc.tar.bz2 otp-38cd77b3e7afbf3973167c5a339381707e3d95bc.zip |
Merge branch 'egil/erts/fix-sigterm/OTP-14290' into maint
* egil/erts/fix-sigterm/OTP-14290:
erts: Make sigterm signal safe for non-smp beam
Diffstat (limited to 'erts/emulator/sys/unix/sys.c')
-rw-r--r-- | erts/emulator/sys/unix/sys.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c index 6459fa064b..55411f83d0 100644 --- a/erts/emulator/sys/unix/sys.c +++ b/erts/emulator/sys/unix/sys.c @@ -148,11 +148,18 @@ volatile int erts_break_requested = 0; #define ERTS_SET_BREAK_REQUESTED (erts_break_requested = 1) #define ERTS_UNSET_BREAK_REQUESTED (erts_break_requested = 0) #endif + +#ifndef ERTS_SMP +volatile Uint erts_signal_sigterm = 0; +#define ERTS_SET_SIGNAL_SIGTERM (erts_signal_sigterm = 1) +#define ERTS_CLEAR_SIGNAL_SIGTERM (erts_signal_sigterm = 0) +#endif + /* set early so the break handler has access to initial mode */ static struct termios initial_tty_mode; static int replace_intr = 0; /* assume yes initially, ttsl_init will clear it */ -int using_oldshell = 1; +int using_oldshell = 1; #ifdef ERTS_ENABLE_KERNEL_POLL @@ -684,11 +691,11 @@ static RETSIGTYPE request_stop(int signum) #ifdef ERTS_SMP smp_sig_notify('S'); #else - stop_requested(); + ERTS_SET_SIGNAL_SIGTERM; + ERTS_CHK_IO_AS_INTR(); #endif } - static ERTS_INLINE void sigusr1_exit(void) { @@ -958,6 +965,13 @@ void erts_do_break_handling(void) erts_smp_thr_progress_unblock(); } +#ifdef ERTS_SIGNAL_SIGTERM +void erts_handle_signal_sigterm(void) { + ERTS_CLEAR_SIGNAL_SIGTERM; + stop_requested(); +} +#endif + /* Fills in the systems representation of the jam/beam process identifier. ** The Pid is put in STRING representation in the supplied buffer, ** no interpretatione of this should be done by the rest of the |