util-runcmd: ignore spurious ECHILD errors
authorAndrew Tridgell <tridge@samba.org>
Tue, 20 Apr 2010 11:45:33 +0000 (21:45 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 20 Apr 2010 13:43:33 +0000 (23:43 +1000)
when we get ECHILD in samba_runcmd it is because the parent has set
SIGCHLD to SIG_IGN. In that case the child status information is
lost. We then have to fallback on the logging of child error messages
for any useful information on what happened to the child.

A longer term fix is to stop using SIG_IGN for SIGCHLD in the standard
process model of s4.

lib/util/util_runcmd.c

index d81a0ace93981d871baf99e5b2ee8e31cb3ec1ff..aa2a3e66727989e2d59227b51ad036243b81a82d 100644 (file)
@@ -241,6 +241,20 @@ static void samba_runcmd_io_handler(struct tevent_context *ev,
                         * stderr, assume its dead */
                        pid_t pid = waitpid(state->pid, &status, 0);
                        if (pid != state->pid) {
+                               if (errno == ECHILD) {
+                                       /* this happens when the
+                                          parent has set SIGCHLD to
+                                          SIG_IGN. In that case we
+                                          can only get error
+                                          information for the child
+                                          via its logging. We should
+                                          stop using SIG_IGN on
+                                          SIGCHLD in the standard
+                                          process model.
+                                       */
+                                       tevent_req_done(req);
+                                       return;
+                               }
                                DEBUG(0,("Error in waitpid() for child %s - %s \n",
                                         state->arg0, strerror(errno)));
                                if (errno == 0) {