From a2086478e642fc2cd1cf64d059fbce37601bda68 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Sat, 21 Jan 2017 13:39:58 +0100 Subject: [PATCH] Ignore rc of child process when killed due to EOF --- CHANGES | 3 +++ xioclose.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 94a280e..af1a1ee 100644 --- a/CHANGES +++ b/CHANGES @@ -57,6 +57,9 @@ corrections: The internal vsnprintf_r function looped or crashed on size parameter with hexadecimal output. + Ignore exit code of child process when it was killed by master due to + EOF + porting: Type conflict between int and sig_atomic_t between declaration and definition of diag_immediate_type and diag_immediate_exit broke diff --git a/xioclose.c b/xioclose.c index b7e168e..d2922f1 100644 --- a/xioclose.c +++ b/xioclose.c @@ -54,9 +54,14 @@ int xioclose1(struct single *pipe) { switch (pipe->howtoend) { case END_KILL: case END_SHUTDOWN_KILL: case END_CLOSE_KILL: if (pipe->para.exec.pid > 0) { - if (Kill(pipe->para.exec.pid, SIGTERM) < 0) { + pid_t pid; + + /* first unregister child pid, so our sigchld handler will not throw an error */ + pid = pipe->para.exec.pid; + pipe->para.exec.pid = 0; + if (Kill(pid, SIGTERM) < 0) { Msg2(errno==ESRCH?E_INFO:E_WARN, "kill(%d, SIGTERM): %s", - pipe->para.exec.pid, strerror(errno)); + pid, strerror(errno)); } } default: