{"id":812724,"url":"http://patchwork.ozlabs.org/api/patches/812724/?format=json","web_url":"http://patchwork.ozlabs.org/project/swupdate/patch/20170912083718.1272-1-christian.storm@siemens.com/","project":{"id":58,"url":"http://patchwork.ozlabs.org/api/projects/58/?format=json","name":"swupdate development","link_name":"swupdate","list_id":"swupdate.googlegroups.com","list_email":"swupdate@googlegroups.com","web_url":"https://github.com/sbabic/swupdate","scm_url":"git://github.com/sbabic/swupdate","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170912083718.1272-1-christian.storm@siemens.com>","list_archive_url":null,"date":"2017-09-12T08:37:18","name":"core: properly handle failed spawn","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"fb3007409e21a0aee6e6c4945f68c1ad626216d0","submitter":{"id":72180,"url":"http://patchwork.ozlabs.org/api/people/72180/?format=json","name":"Storm, Christian","email":"christian.storm@siemens.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/swupdate/patch/20170912083718.1272-1-christian.storm@siemens.com/mbox/","series":[{"id":2633,"url":"http://patchwork.ozlabs.org/api/series/2633/?format=json","web_url":"http://patchwork.ozlabs.org/project/swupdate/list/?series=2633","date":"2017-09-12T08:37:18","name":"core: properly handle failed spawn","version":1,"mbox":"http://patchwork.ozlabs.org/series/2633/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812724/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812724/checks/","tags":{},"related":[],"headers":{"Return-Path":"<swupdate+bncBDD6BWV65QPBB45233GQKGQEJHW7YMY@googlegroups.com>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=googlegroups.com\n\t(client-ip=2a00:1450:4010:c07::23b;\n\thelo=mail-lf0-x23b.google.com;\n\tenvelope-from=swupdate+bncbdd6bwv65qpbb45233gqkgqejhw7ymy@googlegroups.com;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=googlegroups.com header.i=@googlegroups.com\n\theader.b=\"XcRWKQSB\"; dkim-atps=neutral"],"Received":["from mail-lf0-x23b.google.com (mail-lf0-x23b.google.com\n\t[IPv6:2a00:1450:4010:c07::23b])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrysz5r5Kz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 18:40:23 +1000 (AEST)","by mail-lf0-x23b.google.com with SMTP id l196sf258883lfl.10\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 01:40:22 -0700 (PDT)","by 10.46.67.148 with SMTP id z20ls59873lje.0.gmail;\n\tTue, 12 Sep 2017 01:40:19 -0700 (PDT)","from goliath.siemens.de (goliath.siemens.de. [192.35.17.28])\n\tby gmr-mx.google.com with ESMTPS id\n\t74si807568wmf.8.2017.09.12.01.40.19 for <swupdate@googlegroups.com>\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 12 Sep 2017 01:40:19 -0700 (PDT)","from mail3.siemens.de (mail3.siemens.de [139.25.208.14])\n\tby goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id v8C8eIoY008418\n\t(version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK)\n\tfor <swupdate@googlegroups.com>; Tue, 12 Sep 2017 10:40:18 +0200","from MD1KR9XC.ad001.siemens.net ([139.25.69.251])\n\tby mail3.siemens.de (8.15.2/8.15.2) with ESMTP id v8C8eIrY020052;\n\tTue, 12 Sep 2017 10:40:18 +0200"],"ARC-Seal":["i=2; a=rsa-sha256; t=1505205619; cv=pass;\n\td=google.com; s=arc-20160816;\n\tb=OrqjFbAmZeeCe9S3+u+F22erI/jnGqtjrukJKc04JF5gpfTCQnlHbqd/pAPtWtoasn\n\tx1JJ1bea/lPK6v/sLpXdK9jwOAviTszBeMmgQZF2AI9vEr5i1a/9DiB4ngEi9MLBHQJS\n\t/lNqQeto1CF/Swz45xpV2Qnuq/F6kmdqQHWPXCj6N4DQQjR7TzHQfZouDGZsnB9gOTPG\n\tKUM8RZdeHl7f9XO8woPXrQK2E1OhJx27zXoK6EPSehqagg5K+54S4SOTct/R4JdAwvmw\n\tHIGaKAZC0mgh6oPfgmNg/3l9FRlfFwIJCfqHX4aewW0k9wMx1t0vRIyxiLtLuha0G6DL\n\tvBbQ==","i=1; a=rsa-sha256; t=1505205619; cv=none;\n\td=google.com; s=arc-20160816;\n\tb=h6zRc3tu2mo8A3xowB5aqhWndHHRzcVMTaXGGOpwD/f1y9a0seQWQnVWx/cXQmV6BD\n\tU7E5pee2Rv77OEvqTWc6vSiMKMIoo6xqh10DHRaBj2Fti4KJZaIUfHUlyLTn2DRFNEWc\n\tSNC58VOHdS4jYGE4txsP1lF7QMcc/DlAiEZV0YGrEgLDOaLoOT7uGwrgktrwKE0ec68U\n\t8/N42shG5Bd5OYelfNlRpSCLdDuZMDg42SSg9mSw7FHBDdcTuytYaMAqEXDc7kyIeM/U\n\thm7i48S4Vker9OVPoZXDUUr8vjHZLOHrvPw9Yd2Nb4UpmMovBDISy2gnaWwEA6ALhzTH\n\tt/dA=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n\t:list-id:mailing-list:precedence:message-id:date:subject:cc:to:from\n\t:arc-authentication-results:arc-message-signature:mime-version\n\t:sender:dkim-signature:arc-authentication-results;\n\tbh=YWlzks+jbYmZyriETx0l40UAktwxMCkoGVhdHvxtYto=;\n\tb=NBiGLGJB+RjsNyyIKZOMZ4a2VonoMeuTWs6Eilv39fTLmcDGkgMAj/9hjWhnVz98RL\n\tdwWRuO4mvgmtd4tfDZkQb9+QarCE1CFxx6kGvoHIhaoFZ6+svehnInVSNykJnmlpZ0+r\n\ttsYtP1WxJvyTmgJOoYPkNqTFUW1tLlF9nJjXNg6mlvl8nqRRpN2FU4v51kvK74IsNFiW\n\toxfD9PgrBCwphbg1YowGj7hMpx6vIlGxIfnucJiDOtk/cV5XmtA2/sBo5H40Fl6WujLB\n\twBQreItvZSVMU27CPIcSuC7vJZHZ0Hd3c0/bZ4wdPZlPshlGpAhTPa2CKy29IxvE1an1\n\tR+SQ==","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=message-id:date:subject:cc:to:from:arc-authentication-results;\n\tbh=t8XRBcsgkHVk7XT5j7EB/6X5oI+u8d95BapNLUMuVHA=;\n\tb=Mutd0HeCaw3BraN6GIhNlYerJN96cL2wugb5BZ+gO3goa6N+Sn+K4iFhwuRbql88Mz\n\tm+LH0QF0Ncr5Qt2Ds2U3Eyh22X/rMsDQf5NFNfb9w2jaDVLtYYW101Vk84YCYz/q2QR/\n\t1jF4Rb/qR6+a1hNUpP0q9r2/Jfiab2YDR45LF5YLU4+avaNjxdzaHXr5npIswKIPZAT8\n\tVrEuo6HWTh8nc5g6QR+cwaiRzxpMZX6EI4c1ZiNVTTKx4mtav2z69N83cMO9Hi35RMr1\n\tuNn8AMqz+kLgc6q4UMA6AGRoDTHXEGih2YzJWfARWTPb6KBbmJhyjPIyacqZZMv6Iwz7\n\tQ/bw=="],"ARC-Authentication-Results":["i=2; gmr-mx.google.com;\n\tspf=neutral (google.com: 192.35.17.28 is neither permitted nor denied\n\tby best guess record for domain of\n\tchristian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com","i=1; gmr-mx.google.com;\n\tspf=neutral (google.com: 192.35.17.28 is neither permitted nor denied\n\tby best guess record for domain of\n\tchristian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=googlegroups.com; s=20161025;\n\th=sender:mime-version:from:to:cc:subject:date:message-id\n\t:x-original-sender:x-original-authentication-results:precedence\n\t:mailing-list:list-id:list-post:list-help:list-archive\n\t:list-subscribe:list-unsubscribe;\n\tbh=YWlzks+jbYmZyriETx0l40UAktwxMCkoGVhdHvxtYto=;\n\tb=XcRWKQSBRJUJgPJp/4GbNBpexlrrLRdAynUCwhBUSQRaQqr8VcBuHOGfuTGXJaYYXC\n\t/QO8DjQCT2UTyAP8h1hX1emx93+q4ov6YtcKsPS3S7Yq9aCG5Sr/du+whyCy2tGtkCyM\n\tYh/JDoUpKkffDNdFAM1OOmW21HF2gb0Fx0ic4iBerm/v8rpPNlsYoxrAlgU0Qjlq1jpK\n\tjnNY6Lh2I76F7jN1v3f+oUUECYilqqNfVb5rjOJ4RI2PB8cibL02hm0mCQBRrPCl79Yp\n\t0I80Dc2l72Dyu3Sz5ZTgPItoaRXFUEsYURcFAxcB5KowhAtLcuEU6BigOFTSjeZL4eg7\n\t2FtQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=sender:x-gm-message-state:mime-version:from:to:cc:subject:date\n\t:message-id:x-original-sender:x-original-authentication-results\n\t:precedence:mailing-list:list-id:x-spam-checked-in-group:list-post\n\t:list-help:list-archive:list-subscribe:list-unsubscribe;\n\tbh=YWlzks+jbYmZyriETx0l40UAktwxMCkoGVhdHvxtYto=;\n\tb=CkImopq+q2QfbulGS7CjHkBo/+aTeXWx2E4UdLz+r0eYYiXrF0/Exfn/uHNl3C3VWb\n\tvGf325WbX3xfjF1syGsalJWX7gc2nJWdW6o8fJUE/QCsziBx7C5eF27huvmOf2CstBnw\n\t86zHkj78koswgeum4DIBZ7jIkcsRARugWX3f7b3/7KoBneyrDMdzC5JTMGCfYhvjx9hI\n\trVfiNEcqk1LhDQMUa4988k83WTH0qQXHxaNXMADI4D4aQ55AMXSYPF2FeI2maXcsBR5P\n\tC77fUYooARLbYUNY8ly/ASajJSSWMzYfVA/qru0b8IpxzmZli1eZCzbhEOhJ6XqPY183\n\tFhMw==","Sender":"swupdate@googlegroups.com","X-Gm-Message-State":"AHPjjUiY2vKnUDNkdPbebCWsY58OA9KZN4OziPzHIyfN8BBwfpbxrtGO\n\t40q5ihi37ESxCA==","X-Google-Smtp-Source":"ADKCNb5o1SkuIKk8ekiXaVnXMEk9pVNMqQFsZaL2N2UG+CmCpdH1sx7IWyRLHNkL8l50EaVlpfE6XQ==","X-Received":["by 10.46.17.26 with SMTP id f26mr17800lje.21.1505205619752;\n\tTue, 12 Sep 2017 01:40:19 -0700 (PDT)","by 10.46.29.11 with SMTP id d11mr891653ljd.8.1505205619293;\n\tTue, 12 Sep 2017 01:40:19 -0700 (PDT)"],"MIME-Version":"1.0","X-BeenThere":"swupdate@googlegroups.com","Received-SPF":"neutral (google.com: 192.35.17.28 is neither permitted nor\n\tdenied by best guess record for domain of\n\tchristian.storm@siemens.com) client-ip=192.35.17.28; ","From":"Christian Storm <christian.storm@siemens.com>","To":"swupdate@googlegroups.com","Cc":"Christian Storm <christian.storm@siemens.com>","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\n\t(google.com: 192.35.17.28 is neither permitted nor denied by best\n\tguess\n\trecord for domain of christian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com","Content-Type":"text/plain; charset=\"UTF-8\"","Precedence":"list","Mailing-list":"list swupdate@googlegroups.com;\n\tcontact swupdate+owners@googlegroups.com","List-ID":"<swupdate.googlegroups.com>","X-Spam-Checked-In-Group":"swupdate@googlegroups.com","X-Google-Group-Id":"605343134186","List-Post":"<https://groups.google.com/group/swupdate/post>,\n\t<mailto:swupdate@googlegroups.com>","List-Help":"<https://groups.google.com/support/>,\n\t<mailto:swupdate+help@googlegroups.com>","List-Archive":"<https://groups.google.com/group/swupdate","List-Subscribe":"<https://groups.google.com/group/swupdate/subscribe>,\n\t<mailto:swupdate+subscribe@googlegroups.com>","List-Unsubscribe":"<mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>,\n\t<https://groups.google.com/group/swupdate/subscribe>"},"content":"Spawning has failed. This may happen if\n(1) a swupdate_process start() method unexpectedly returned or\n(2) execvp() failed, e.g., if the executable file is not found.\nIn this case, exit this (child) process to not continue initialization\nin this and the main process as the two share .text\n\nSigned-off-by: Christian Storm <christian.storm@siemens.com>\n---\n core/pctl.c | 13 +++++++++----\n 1 file changed, 9 insertions(+), 4 deletions(-)","diff":"diff --git a/core/pctl.c b/core/pctl.c\nindex 182cb60..6a2822e 100644\n--- a/core/pctl.c\n+++ b/core/pctl.c\n@@ -160,8 +160,13 @@ static int spawn_process(struct swupdate_task *task,\n \n \tif (start)\n \t\treturn (*start)(cfgname, ac, av);\n-\telse\n-\t\treturn execvp(cmdline, av);\n+\telse {\n+\t\tif (execvp(cmdline, av) == -1) {\n+\t\t\tINFO(\"Spawning process %s failed: %s\", av[0], strerror(errno));\n+\t\t\treturn -1;\n+\t\t}\n+\t\treturn 0;\n+\t}\n }\n \n static void start_swupdate_subprocess(sourcetype type,\n@@ -177,8 +182,8 @@ static void start_swupdate_subprocess(sourcetype type,\n \tprocs[nprocs].name = name;\n \tprocs[nprocs].type = type;\n \tif (spawn_process(&procs[nprocs], uid, gid, cfgfile, argc, argv, start, cmdline) < 0) {\n-\t\tERROR(\"SPAWN %s failed, exiting...\\n\", name);\n-\t\treturn;\n+\t\tERROR(\"Spawning %s failed, exiting process...\\n\", name);\n+\t\texit(1);\n \t}\n \n \tTRACE(\"Started %s with pid %d and fd %d\", name, procs[nprocs].pid, procs[nprocs].pipe);\n","prefixes":[]}