aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2018-09-10 10:47:52 +0200
committerRickard Green <[email protected]>2018-09-10 11:33:24 +0200
commitda4c24bf8fc7bb2ee0d0a66d9fcfe6344d7c0c8a (patch)
treeb57c3cd18ad0dcd0e638742fcb3d75742dc38dac
parent30e5321740b96b3a8984611b6f821692716d0555 (diff)
downloadotp-da4c24bf8fc7bb2ee0d0a66d9fcfe6344d7c0c8a.tar.gz
otp-da4c24bf8fc7bb2ee0d0a66d9fcfe6344d7c0c8a.tar.bz2
otp-da4c24bf8fc7bb2ee0d0a66d9fcfe6344d7c0c8a.zip
Restore default SIGTERM behaviour for port programs
erl_child_setup program ignores TERM signals as of ERTS version 10.0 (cff8dce0). This setting was unfortunately inherited by port programs. This commit restores handling of TERM signals in port programs to the default behavior. That is, terminate the process.
-rw-r--r--erts/emulator/sys/unix/erl_child_setup.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/erts/emulator/sys/unix/erl_child_setup.c b/erts/emulator/sys/unix/erl_child_setup.c
index 221ee2a69d..129861ebd5 100644
--- a/erts/emulator/sys/unix/erl_child_setup.c
+++ b/erts/emulator/sys/unix/erl_child_setup.c
@@ -133,6 +133,7 @@ static int sigchld_pipe[2];
static int
start_new_child(int pipes[])
{
+ struct sigaction sa;
int errln = -1;
int size, res, i, pos = 0;
char *buff, *o_buff;
@@ -143,6 +144,16 @@ start_new_child(int pipes[])
/* only child executes here */
+ /* Restore default handling of sigterm... */
+ sa.sa_handler = SIG_DFL;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ if (sigaction(SIGTERM, &sa, 0) == -1) {
+ perror(NULL);
+ exit(1);
+ }
+
do {
res = read(pipes[0], (char*)&size, sizeof(size));
} while(res < 0 && (errno == EINTR || errno == ERRNO_BLOCK));