From patchwork Tue Jun 24 23:21:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Shankar X-Patchwork-Id: 1707 Received: (qmail 26068 invoked by alias); 24 Jun 2014 23:19:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 26058 invoked by uid 89); 24 Jun 2014 23:19:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: arati.lostca.se Date: Wed, 25 Jun 2014 01:21:24 +0200 From: Arjun Shankar To: libc-alpha@sourceware.org Subject: [PATCH] Correctly report nscd child process status. Message-ID: <20140625012124.4c63692a@zion> Mime-Version: 1.0 Hi, The nscd parent process returns the result of a `wait' call rather than the exit status of the child it waits for. These two aren't exactly the same. In my case (and probably on most machines), the exit status is in the 2nd LSB of the result of `wait', and so: e.g. if the nscd child process returns 1, the parent returns 1 << 8, which Bash happily reports as 0. This patch should fix that. Cheers, Arjun --- nscd/nscd.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/nscd/nscd.c b/nscd/nscd.c index 3dd1135..298bdcc 100644 --- a/nscd/nscd.c +++ b/nscd/nscd.c @@ -612,7 +612,8 @@ monitor_child (int fd) method, like a segfault. */ if (ret <= 0 || child_ret != 0) { - int err = wait (&child_ret); + int status; + int err = wait (&status); if (err < 0) { @@ -620,13 +621,16 @@ monitor_child (int fd) return 1; } - fprintf (stderr, _("child exited with status %d"), - WEXITSTATUS (child_ret)); - if (WIFSIGNALED (child_ret)) - fprintf (stderr, _(", terminated by signal %d.\n"), - WTERMSIG (child_ret)); - else - fprintf (stderr, ".\n"); + if (WIFEXITED (status)) + { + child_ret = WEXITSTATUS (status); + fprintf (stderr, _("child exited with status %d.\n"), child_ret); + } + if (WIFSIGNALED (status)) + { + child_ret = WTERMSIG (status); + fprintf (stderr, _("child terminated by signal %d.\n"), child_ret); + } } /* We have the child status, so exit with that code. */