From patchwork Fri Oct 30 13:16:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wallen, Carl \(Nokia - FI/Espoo\)" X-Patchwork-Id: 55834 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp1215701lbr; Fri, 30 Oct 2015 06:17:18 -0700 (PDT) X-Received: by 10.50.111.170 with SMTP id ij10mr3007321igb.88.1446211038747; Fri, 30 Oct 2015 06:17:18 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id rp8si2364652igb.46.2015.10.30.06.17.18; Fri, 30 Oct 2015 06:17:18 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2F8BA62C2D; Fri, 30 Oct 2015 13:17:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 4618962C41; Fri, 30 Oct 2015 13:16:16 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B9BAB62C35; Fri, 30 Oct 2015 13:16:11 +0000 (UTC) Received: from demumfd001.nsn-inter.net (demumfd001.nsn-inter.net [93.183.12.32]) by lists.linaro.org (Postfix) with ESMTPS id 8183C62C2D for ; Fri, 30 Oct 2015 13:16:10 +0000 (UTC) Received: from demuprx017.emea.nsn-intra.net ([10.150.129.56]) by demumfd001.nsn-inter.net (8.15.2/8.15.2) with ESMTPS id t9UDG9w6005936 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 30 Oct 2015 13:16:09 GMT Received: from 10.144.19.15 ([10.144.164.243]) by demuprx017.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id t9UDG7Nt031613 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Fri, 30 Oct 2015 14:16:08 +0100 From: Carl Wallen To: lng-odp@lists.linaro.org Date: Fri, 30 Oct 2015 15:16:06 +0200 Message-Id: <1446210967-23576-3-git-send-email-carl.wallen@nokia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446210967-23576-1-git-send-email-carl.wallen@nokia.com> References: <1446210967-23576-1-git-send-email-carl.wallen@nokia.com> X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 1464 X-purgate-ID: 151667::1446210969-00000D72-6929E928/0/0 X-Topics: patch Subject: [lng-odp] [PATCH 2/3] helper: linux: examine the cause for child process termination X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" odph_linux_process_wait_n(): This patch helps catch child abnormal termination by breaking out of the wait()-loop on error. Examine what caused a forked child process to terminate. Do not wait() for other children if the termination status indicates error in the child, return -1 instead. Children that are not waited for will be terminated by the SIGTERM signal once the parent exits (requested by the prctl(PR_SET_PDEATHSIG, SIGTERM) call after child fork) even if the parent does not perform any explicit clean-up actions. Signed-off-by: Carl Wallen --- helper/linux.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/helper/linux.c b/helper/linux.c index 3d5da18..6e70206 100644 --- a/helper/linux.c +++ b/helper/linux.c @@ -224,7 +224,21 @@ int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num) } if (j == num) { - ODPH_ERR("Bad pid\n"); + ODPH_ERR("Bad pid:%d\n", (int)pid); + return -1; + } + + /* Examine the child process' termination status */ + if (WIFEXITED(status) && WEXITSTATUS(status) != EXIT_SUCCESS) { + ODPH_ERR("Child exit status:%d (pid:%d)\n", + WEXITSTATUS(status), (int)pid); + return -1; + } + if (WIFSIGNALED(status)) { + int signo = WTERMSIG(status); + + ODPH_ERR("Child term signo:%d - %s (pid:%d)\n", + signo, strsignal(signo), (int)pid); return -1; } }