[{"id":1766775,"web_url":"http://patchwork.ozlabs.org/comment/1766775/","msgid":"<15f00b70-b06a-c25e-c6b1-67e5f2276ef7@denx.de>","list_archive_url":null,"date":"2017-09-12T08:52:02","subject":"Re: [swupdate] [PATCH] core: properly handle failed spawn","submitter":{"id":5771,"url":"http://patchwork.ozlabs.org/api/people/5771/","name":"Stefano Babic","email":"sbabic@denx.de"},"content":"Hi Christian,\n\nOn 12/09/2017 10:37, Christian Storm wrote:\n> 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.\n\nRight.\n\n> In this case, exit this (child) process to not continue initialization\n> in this and the main process as the two share .text\n> \n\nAgree.\n\n> Signed-off-by: Christian Storm <christian.storm@siemens.com>\n> ---\n>  core/pctl.c | 13 +++++++++----\n>  1 file changed, 9 insertions(+), 4 deletions(-)\n> \n> diff --git a/core/pctl.c b/core/pctl.c\n> index 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> \n\nAcked-by: Stefano Babic <sbabic@denx.de>\n\nBest regards,\nStefano","headers":{"Return-Path":"<swupdate+bncBAABBOOA33GQKGQEDZWEGZQ@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::23a;\n\thelo=mail-lf0-x23a.google.com;\n\tenvelope-from=swupdate+bncbaabbooa33gqkgqedzwegzq@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=\"FI3uGuDp\"; dkim-atps=neutral"],"Received":["from mail-lf0-x23a.google.com (mail-lf0-x23a.google.com\n\t[IPv6:2a00:1450:4010:c07::23a])\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 3xrz7d2sBpz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 18:52:12 +1000 (AEST)","by mail-lf0-x23a.google.com with SMTP id u21sf269034lfk.20\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 01:52:12 -0700 (PDT)","by 10.46.81.65 with SMTP id b1ls60974lje.25.gmail; Tue, 12 Sep 2017\n\t01:52:09 -0700 (PDT)","from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9])\n\tby gmr-mx.google.com with ESMTPS id\n\tc142si808530wmh.3.2017.09.12.01.52.09\n\tfor <swupdate@googlegroups.com>\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 12 Sep 2017 01:52:09 -0700 (PDT)","from frontend03.mail.m-online.net (unknown [192.168.6.182])\n\tby mail-out.m-online.net (Postfix) with ESMTP id 3xrz7Y0Nv9z1qwpx;\n\tTue, 12 Sep 2017 10:52:09 +0200 (CEST)","from localhost (dynscan3.mnet-online.de [192.168.6.84])\n\tby mail.m-online.net (Postfix) with ESMTP id 3xrz7Y06T8z1qsQ5;\n\tTue, 12 Sep 2017 10:52:09 +0200 (CEST)","from mail.mnet-online.de ([192.168.8.182])\n\tby localhost (dynscan3.mail.m-online.net [192.168.6.84]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id 1nFDfNJfp4bz; Tue, 12 Sep 2017 10:52:06 +0200 (CEST)","from babic.homelinux.org\n\t(host-88-217-136-221.customer.m-online.net [88.217.136.221])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby mail.mnet-online.de (Postfix) with ESMTPS;\n\tTue, 12 Sep 2017 10:52:06 +0200 (CEST)","from localhost (mail.babic.homelinux.org [127.0.0.1])\n\tby babic.homelinux.org (Postfix) with ESMTP id 3168F45405CE;\n\tTue, 12 Sep 2017 10:52:06 +0200 (CEST)","from babic.homelinux.org ([127.0.0.1])\n\tby localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id Rl4FNPV05klE; Tue, 12 Sep 2017 10:52:02 +0200 (CEST)","from [192.168.178.132] (papero.fritz.box [192.168.178.132])\n\tby babic.homelinux.org (Postfix) with ESMTP id 8C32745405CD;\n\tTue, 12 Sep 2017 10:52:02 +0200 (CEST)"],"ARC-Seal":["i=2; a=rsa-sha256; t=1505206329; cv=pass;\n\td=google.com; s=arc-20160816;\n\tb=0PVXmPTeKjaypC4DxFJcvZ9CKrmPvFkuBb0lx5H34aqD8j54n6dw5Sqz+GdHicNdEm\n\tX5DmQtt8e70BZmIAxV6ZL9wSlqkL5+f/5Mdhoa3x+JyZMZKuFjEk3MgGUja3pRvlnLjY\n\tK1abWLY+45itGEGFbX116bJn4Cdx3cnRpGs9zKJb8tTSKpX1l7ikP4lQLk/RONOo6f+M\n\tL3/kjzsiYqWw0b0fyHj+4M9S2tJWvm5cUsnuRfQufFYd6HlYWJr1rM+lEKUTtS58y7A1\n\taOx2lKchxrzAmTGD+GS6c/w4DbnORbRCvZ5dBZfbqX0xLxXgEiNTy8jE1EMTitR2G8Ob\n\tLpqw==","i=1; a=rsa-sha256; t=1505206329; cv=none;\n\td=google.com; s=arc-20160816;\n\tb=QH1lkwemen8tIODiVLS6Wq9JppSidcJmRQegfunjMJ77SQnWvQDIMcsBuy6yykvwIg\n\tcKV/d4L7DZPLlyIdfAky1U3yrowrrXZ0WyIEZH+B0Fs1EE5ZihSxPjBu5xqeUDKwpe1/\n\t5OJ40IYdvGSMAfTeqvo21gtkk1feLnSaAG/ZYFeleE+eKcnpQEIq2sSsXOIX0pEGiGzW\n\tJlKpj+kLecv76exmHaJS+tehxdphzaTgdMDT3uhwyMa1M4oxYR7S8LU56uDgaZsJFfH8\n\tAq6QoOD8nGUaSWijYeY2vLye5RIaQXe/bGRpK8+TruRagoexPB+SITHgSz4NOKNkCgel\n\tF99Q=="],"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:content-language:in-reply-to\n\t:mime-version:user-agent:date:message-id:from:references:to:subject\n\t:arc-authentication-results:arc-message-signature:sender\n\t:dkim-signature:arc-authentication-results;\n\tbh=dPeks2XSUsvHuY0c90O5fINSyIaOTjl+0BjEqlAc+T8=;\n\tb=V8YMP9pUnZJFnjlk2Yh2bOTJGLZaRVB+54rgKURfpp6hwNBOQU5aLldy6n1y4//VGF\n\tFwCr6DVXmLdYCzLEj+awrquwcVjFGCTarPIrgQZOM41mJYOx2iXv6I1rx9VGjcolAcFD\n\t7SuN7SVey6Iyby76XLyzXFDvRvwAXu9qFeSFm0OJgyUZSkap03zcyc6LSZXAtcsYOYLx\n\tZgYMNi1R4Q7wH6fo9F8WPWh/c+7qDpAwE17OSwFGi+n0A400r2uNDecJIBlNzUYQPGLW\n\trMYBut5A5TeI1fhoAuFnQNmYIPrnRbj5W7/cYjSq0Sv6txgrOdtTVZmSRfEjugpQqrr2\n\tZcCQ==","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=content-transfer-encoding:content-language:in-reply-to:mime-version\n\t:user-agent:date:message-id:from:references:to:subject\n\t:arc-authentication-results;\n\tbh=oC0rIiX0bslsf8nKDxRpbwOeF3Bt6HlVsjhArYl81Yo=;\n\tb=iXdQIRP6GkjblMKSMpxWQIXySHmKeOm8mA1IJu+jK+ez4Q85FdEqbr8nfVuAS8XTR7\n\tQfQOF7fowAPY7Ci5baNn2O94DHkf9MCVjutRr09O1PssD/SOux4JQQovXj/aaFwHSVsz\n\tojQRwDvdPykcgvZKvXPz+onwE0ATDdiYEW8u7Ie7WpVrJB3Ouk0wwfYGqwgydt1rYWWY\n\tyzzJPzhJ3sYlBD4wXwyAFkM6g7OnHbuxiGMHC+dexKZfKtcxkOFTCf30gzk5+Y5dfoS4\n\twp9YcWoBGkmhXTpxBKCFCJkTHNklm5njjFkm5WmiBWbMUnpPcT2mVsYEJRRdk256fjkK\n\tLpnQ=="],"ARC-Authentication-Results":["i=2; gmr-mx.google.com;\n\tspf=neutral (google.com: 212.18.0.9 is neither permitted nor denied\n\tby best guess record for domain of sbabic@denx.de)\n\tsmtp.mailfrom=sbabic@denx.de","i=1; gmr-mx.google.com;\n\tspf=neutral (google.com: 212.18.0.9 is neither permitted nor denied\n\tby best guess record for domain of sbabic@denx.de)\n\tsmtp.mailfrom=sbabic@denx.de"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=googlegroups.com; s=20161025;\n\th=sender:subject:to:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:x-original-sender\n\t:x-original-authentication-results:precedence:mailing-list:list-id\n\t:list-post:list-help:list-archive:list-subscribe:list-unsubscribe;\n\tbh=dPeks2XSUsvHuY0c90O5fINSyIaOTjl+0BjEqlAc+T8=;\n\tb=FI3uGuDphHjR2kes+FhH4XZhNE23ftVO7TbJGKBdhS+vsSYw+c3soRBiQ+xDjrdIDK\n\tfQRp4/BT018BunPXRZ0t3HIt2LHECz0MR1OFKUWdjeacup0fWwsxCPy5Q7XN3eS7KRuH\n\tCqd2h/Rhj8KFETHm/XjoS5J0ktusJEI9Vl4ywVDYfu8xbxWSmtLblV/s/7ByNKWGwFSW\n\tsHVN03DxM0jWk/FX5736lipin3oAzuqVXH1NxlUaCN5vMpHXW7IqdiqiSA7jfsFChP/V\n\tqSy9SbuC2qLrw28ZfVyjY24L3idW+yAApz3KplO61cLi315YXz3MEN7OjGCGMAH/9ECL\n\t3FIw==","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:subject:to:references:from:message-id\n\t:date:user-agent:mime-version:in-reply-to:content-language\n\t:x-original-sender:x-original-authentication-results:precedence\n\t:mailing-list:list-id:x-spam-checked-in-group:list-post:list-help\n\t:list-archive:list-subscribe:list-unsubscribe;\n\tbh=dPeks2XSUsvHuY0c90O5fINSyIaOTjl+0BjEqlAc+T8=;\n\tb=V6S0NdXky9MkMfGTDySm+WCoJecZNdfobWRTYZPJRxsSnvVQ8Xphg7Tubyf845P7by\n\tGqyOn1rOfcewHRpri4DRedmVkWCVSk68ixYx05b3eK6AEx7Oe8L83mBuTGqFxsBivaus\n\tSm8ecZ1AFJJC6ccuTWNAIXZJ5l8uQqPJLBfHijv4fFJc/F+/J7s+lU68dq5mfDsTnT5L\n\tg6boijQeiMHKh/It5r2Clxy5DiM1N7dNOitsM5Kelj9lchPFOk1h5OagYNmkwmHrSFoQ\n\t/GrRAEI7gb7VAfn6bSq7CopoKwQLhSIcbwtNTzKk8tdJMlXAuAf8ABvKDmd8zGUA1bEf\n\t7qCg==","Sender":"swupdate@googlegroups.com","X-Gm-Message-State":"AHPjjUiNSqhm22qNpImYqvKPn7r2/iJxTOwPsM9YX5Bi9fjXJDQjOtaC\n\tMTtu6eZCICLOtQ==","X-Google-Smtp-Source":"ADKCNb4rN11/p5OaIYwrGat0cJi6tCtQCIMiY1J9IeHR8SA4RhBcZw2ue1tfFdBMrHYK/cwtzHmaRA==","X-Received":["by 10.46.20.79 with SMTP id 15mr28024lju.29.1505206329761;\n\tTue, 12 Sep 2017 01:52:09 -0700 (PDT)","by 10.46.32.39 with SMTP id g39mr1149952ljg.17.1505206329292;\n\tTue, 12 Sep 2017 01:52:09 -0700 (PDT)"],"X-BeenThere":"swupdate@googlegroups.com","Received-SPF":"neutral (google.com: 212.18.0.9 is neither permitted nor\n\tdenied by best guess record for domain of sbabic@denx.de)\n\tclient-ip=212.18.0.9; ","X-Virus-Scanned":["amavisd-new at mnet-online.de","Debian amavisd-new at babic.homelinux.org"],"Subject":"Re: [swupdate] [PATCH] core: properly handle failed spawn","To":"Christian Storm <christian.storm@siemens.com>, swupdate@googlegroups.com","References":"<20170912083718.1272-1-christian.storm@siemens.com>","From":"Stefano Babic <sbabic@denx.de>","Message-ID":"<15f00b70-b06a-c25e-c6b1-67e5f2276ef7@denx.de>","Date":"Tue, 12 Sep 2017 10:52:02 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170912083718.1272-1-christian.storm@siemens.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Language":"de-DE","X-Original-Sender":"sbabic@denx.de","X-Original-Authentication-Results":"gmr-mx.google.com;       spf=neutral\n\t(google.com: 212.18.0.9 is neither permitted nor denied by best guess\n\trecord\n\tfor domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de","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>"}}]