File 0446-Restore-default-SIGTERM-behaviour-for-port-programs.patch of Package erlang

From da4c24bf8fc7bb2ee0d0a66d9fcfe6344d7c0c8a Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Mon, 10 Sep 2018 10:47:52 +0200
Subject: [PATCH] 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.
---
 erts/emulator/sys/unix/erl_child_setup.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

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));
-- 
2.16.4

openSUSE Build Service is sponsored by