From patchwork Tue Sep 12 08:37:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 812724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::23b; helo=mail-lf0-x23b.google.com; envelope-from=swupdate+bncbdd6bwv65qpbb45233gqkgqejhw7ymy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="XcRWKQSB"; dkim-atps=neutral Received: from mail-lf0-x23b.google.com (mail-lf0-x23b.google.com [IPv6:2a00:1450:4010:c07::23b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xrysz5r5Kz9s7g for ; Tue, 12 Sep 2017 18:40:23 +1000 (AEST) Received: by mail-lf0-x23b.google.com with SMTP id l196sf258883lfl.10 for ; Tue, 12 Sep 2017 01:40:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1505205619; cv=pass; d=google.com; s=arc-20160816; b=OrqjFbAmZeeCe9S3+u+F22erI/jnGqtjrukJKc04JF5gpfTCQnlHbqd/pAPtWtoasn x1JJ1bea/lPK6v/sLpXdK9jwOAviTszBeMmgQZF2AI9vEr5i1a/9DiB4ngEi9MLBHQJS /lNqQeto1CF/Swz45xpV2Qnuq/F6kmdqQHWPXCj6N4DQQjR7TzHQfZouDGZsnB9gOTPG KUM8RZdeHl7f9XO8woPXrQK2E1OhJx27zXoK6EPSehqagg5K+54S4SOTct/R4JdAwvmw HIGaKAZC0mgh6oPfgmNg/3l9FRlfFwIJCfqHX4aewW0k9wMx1t0vRIyxiLtLuha0G6DL vBbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=YWlzks+jbYmZyriETx0l40UAktwxMCkoGVhdHvxtYto=; b=NBiGLGJB+RjsNyyIKZOMZ4a2VonoMeuTWs6Eilv39fTLmcDGkgMAj/9hjWhnVz98RL dwWRuO4mvgmtd4tfDZkQb9+QarCE1CFxx6kGvoHIhaoFZ6+svehnInVSNykJnmlpZ0+r tsYtP1WxJvyTmgJOoYPkNqTFUW1tLlF9nJjXNg6mlvl8nqRRpN2FU4v51kvK74IsNFiW oxfD9PgrBCwphbg1YowGj7hMpx6vIlGxIfnucJiDOtk/cV5XmtA2/sBo5H40Fl6WujLB wBQreItvZSVMU27CPIcSuC7vJZHZ0Hd3c0/bZ4wdPZlPshlGpAhTPa2CKy29IxvE1an1 R+SQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.28 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=YWlzks+jbYmZyriETx0l40UAktwxMCkoGVhdHvxtYto=; b=XcRWKQSBRJUJgPJp/4GbNBpexlrrLRdAynUCwhBUSQRaQqr8VcBuHOGfuTGXJaYYXC /QO8DjQCT2UTyAP8h1hX1emx93+q4ov6YtcKsPS3S7Yq9aCG5Sr/du+whyCy2tGtkCyM Yh/JDoUpKkffDNdFAM1OOmW21HF2gb0Fx0ic4iBerm/v8rpPNlsYoxrAlgU0Qjlq1jpK jnNY6Lh2I76F7jN1v3f+oUUECYilqqNfVb5rjOJ4RI2PB8cibL02hm0mCQBRrPCl79Yp 0I80Dc2l72Dyu3Sz5ZTgPItoaRXFUEsYURcFAxcB5KowhAtLcuEU6BigOFTSjeZL4eg7 2FtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=YWlzks+jbYmZyriETx0l40UAktwxMCkoGVhdHvxtYto=; b=CkImopq+q2QfbulGS7CjHkBo/+aTeXWx2E4UdLz+r0eYYiXrF0/Exfn/uHNl3C3VWb vGf325WbX3xfjF1syGsalJWX7gc2nJWdW6o8fJUE/QCsziBx7C5eF27huvmOf2CstBnw 86zHkj78koswgeum4DIBZ7jIkcsRARugWX3f7b3/7KoBneyrDMdzC5JTMGCfYhvjx9hI rVfiNEcqk1LhDQMUa4988k83WTH0qQXHxaNXMADI4D4aQ55AMXSYPF2FeI2maXcsBR5P C77fUYooARLbYUNY8ly/ASajJSSWMzYfVA/qru0b8IpxzmZli1eZCzbhEOhJ6XqPY183 FhMw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AHPjjUiY2vKnUDNkdPbebCWsY58OA9KZN4OziPzHIyfN8BBwfpbxrtGO 40q5ihi37ESxCA== X-Google-Smtp-Source: ADKCNb5o1SkuIKk8ekiXaVnXMEk9pVNMqQFsZaL2N2UG+CmCpdH1sx7IWyRLHNkL8l50EaVlpfE6XQ== X-Received: by 10.46.17.26 with SMTP id f26mr17800lje.21.1505205619752; Tue, 12 Sep 2017 01:40:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.46.67.148 with SMTP id z20ls59873lje.0.gmail; Tue, 12 Sep 2017 01:40:19 -0700 (PDT) X-Received: by 10.46.29.11 with SMTP id d11mr891653ljd.8.1505205619293; Tue, 12 Sep 2017 01:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505205619; cv=none; d=google.com; s=arc-20160816; b=h6zRc3tu2mo8A3xowB5aqhWndHHRzcVMTaXGGOpwD/f1y9a0seQWQnVWx/cXQmV6BD U7E5pee2Rv77OEvqTWc6vSiMKMIoo6xqh10DHRaBj2Fti4KJZaIUfHUlyLTn2DRFNEWc SNC58VOHdS4jYGE4txsP1lF7QMcc/DlAiEZV0YGrEgLDOaLoOT7uGwrgktrwKE0ec68U 8/N42shG5Bd5OYelfNlRpSCLdDuZMDg42SSg9mSw7FHBDdcTuytYaMAqEXDc7kyIeM/U hm7i48S4Vker9OVPoZXDUUr8vjHZLOHrvPw9Yd2Nb4UpmMovBDISy2gnaWwEA6ALhzTH t/dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=t8XRBcsgkHVk7XT5j7EB/6X5oI+u8d95BapNLUMuVHA=; b=Mutd0HeCaw3BraN6GIhNlYerJN96cL2wugb5BZ+gO3goa6N+Sn+K4iFhwuRbql88Mz m+LH0QF0Ncr5Qt2Ds2U3Eyh22X/rMsDQf5NFNfb9w2jaDVLtYYW101Vk84YCYz/q2QR/ 1jF4Rb/qR6+a1hNUpP0q9r2/Jfiab2YDR45LF5YLU4+avaNjxdzaHXr5npIswKIPZAT8 VrEuo6HWTh8nc5g6QR+cwaiRzxpMZX6EI4c1ZiNVTTKx4mtav2z69N83cMO9Hi35RMr1 uNn8AMqz+kLgc6q4UMA6AGRoDTHXEGih2YzJWfARWTPb6KBbmJhyjPIyacqZZMv6Iwz7 Q/bw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.28 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id 74si807568wmf.8.2017.09.12.01.40.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 01:40:19 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.28 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id v8C8eIoY008418 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 12 Sep 2017 10:40:18 +0200 Received: from MD1KR9XC.ad001.siemens.net ([139.25.69.251]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id v8C8eIrY020052; Tue, 12 Sep 2017 10:40:18 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH] core: properly handle failed spawn Date: Tue, 12 Sep 2017 10:37:18 +0200 Message-Id: <20170912083718.1272-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.1 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.28 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Spawning has failed. This may happen if (1) a swupdate_process start() method unexpectedly returned or (2) execvp() failed, e.g., if the executable file is not found. In this case, exit this (child) process to not continue initialization in this and the main process as the two share .text Signed-off-by: Christian Storm Acked-by: Stefano Babic --- core/pctl.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/pctl.c b/core/pctl.c index 182cb60..6a2822e 100644 --- a/core/pctl.c +++ b/core/pctl.c @@ -160,8 +160,13 @@ static int spawn_process(struct swupdate_task *task, if (start) return (*start)(cfgname, ac, av); - else - return execvp(cmdline, av); + else { + if (execvp(cmdline, av) == -1) { + INFO("Spawning process %s failed: %s", av[0], strerror(errno)); + return -1; + } + return 0; + } } static void start_swupdate_subprocess(sourcetype type, @@ -177,8 +182,8 @@ static void start_swupdate_subprocess(sourcetype type, procs[nprocs].name = name; procs[nprocs].type = type; if (spawn_process(&procs[nprocs], uid, gid, cfgfile, argc, argv, start, cmdline) < 0) { - ERROR("SPAWN %s failed, exiting...\n", name); - return; + ERROR("Spawning %s failed, exiting process...\n", name); + exit(1); } TRACE("Started %s with pid %d and fd %d", name, procs[nprocs].pid, procs[nprocs].pipe);