]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3050] Fix for bug #2960 causes sntp to print a spurious error message
authorJuergen Perlinger <perlinger@ntp.org>
Sun, 4 Sep 2016 15:37:34 +0000 (17:37 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Sun, 4 Sep 2016 15:37:34 +0000 (17:37 +0200)
bk: 57cc3fbe0gjFzc9fMfCLk_f5YZgEkA

ChangeLog
libntp/work_fork.c

index 0805467dc6b9b1ce7768a039f6a2d87af37546b9..a220c0c9487fca714552d012a754d4b52bddb2dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+---
+* [Bug 3050]  Fix for bug #2960 causes [...] spurious error message.
+  <perlinger@ntp.org>
+  - patches by Reinhard Max <max@suse.com> and Havard Eidnes <he@uninett.no>
+
 ---
 (4.2.8p8) 2016/06/02 Released by Harlan Stenn <stenn@ntp.org>
 
index 6c9545aa9cbc0ac39b340124e00e0e91bc7032ec..8223fdd2f9b29b5ce531422fc5d8b992ca9c2084 100644 (file)
@@ -114,18 +114,24 @@ interrupt_worker_sleep(void)
 
 /*
  * harvest_child_status() runs in the parent.
+ *
+ * Note the error handling -- this is an interaction with SIGCHLD.
+ * SIG_IGN on SIGCHLD on some OSes means do not wait but reap
+ * automatically. Since we're not really interested in the result code,
+ * we simply ignore the error.
  */
 static void
 harvest_child_status(
        blocking_child *        c
        )
 {
-       if (c->pid)
-       {
+       if (c->pid) {
                /* Wait on the child so it can finish terminating */
                if (waitpid(c->pid, NULL, 0) == c->pid)
                        TRACE(4, ("harvested child %d\n", c->pid));
-               else msyslog(LOG_ERR, "error waiting on child %d: %m", c->pid);
+               else if (errno != ECHILD)
+                       msyslog(LOG_ERR, "error waiting on child %d: %m", c->pid);
+               c->pid = 0;
        }
 }
 
@@ -162,7 +168,6 @@ cleanup_after_child(
                close(c->resp_read_pipe);
                c->resp_read_pipe = -1;
        }
-       c->pid = 0;
        c->resp_read_ctx = NULL;
        DEBUG_INSIST(-1 == c->req_read_pipe);
        DEBUG_INSIST(-1 == c->resp_write_pipe);
@@ -461,7 +466,10 @@ fork_blocking_child(
        fflush(stdout);
        fflush(stderr);
 
-       signal_no_reset(SIGCHLD, SIG_IGN);
+       /* [BUG 3050] setting SIGCHLD to SIG_IGN likely causes unwanted
+        * or undefined effects. We don't do it and leave SIGCHLD alone.
+        */
+       /* signal_no_reset(SIGCHLD, SIG_IGN); */
 
        childpid = fork();
        if (-1 == childpid) {