From nobody Thu May 16 23:09:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1586290508; cv=none; d=zohomail.com; s=zohoarc; b=MwKY9kcUbE5QoS9nVKuUfHX/kPUhrg1KYY7UY3+jdMJ/UMHyQzGI7pccoJpfhIY7bMRY5CUXFmA99dKWB9gSKTSULSd7sf/b77eix1bKCPsQOnIxx2j5CELwl5ZonoReWLTvbDHk9m0tK8kn+yhr5niWhNOaBV84vwjQCpZWA10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586290508; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=CHs6cxbkTj1ElHA7wXIy9A7gqcG8PwATTttXRLULfSQ=; b=ag+3wZqCCglpp5+eIMgj0Ul6iLwTRHz/UjdYgUZoNIEDH2tqAGr636R0Ep/rtgKPTicKIFz3Fi+HHcBIgR9PvFxea4pXq29U0JohNO0wVBfJub4h2kpHg0YZUF3bnXVhxUCKEDHZrnLh384BezI3/kPXWC2gGdJxw5vHXHJ9OB8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1586290508862688.7220395139736; Tue, 7 Apr 2020 13:15:08 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-461-ph15QPykO6mezgYIRZz1uA-1; Tue, 07 Apr 2020 16:15:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1814149C0; Tue, 7 Apr 2020 20:14:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B1961BC6D; Tue, 7 Apr 2020 20:14:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D4EDD18089C8; Tue, 7 Apr 2020 20:14:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 037KEsif013803 for ; Tue, 7 Apr 2020 16:14:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id E4D5C20316E0; Tue, 7 Apr 2020 20:14:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E065A2026D69 for ; Tue, 7 Apr 2020 20:14:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C3BC0800297 for ; Tue, 7 Apr 2020 20:14:50 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-256-ANu-9S75MIyF2pIGDgxXAg-1; Tue, 07 Apr 2020 16:14:43 -0400 Received: by mail-wr1-f67.google.com with SMTP id w15so5314224wrv.10 for ; Tue, 07 Apr 2020 13:14:43 -0700 (PDT) Received: from localhost.localdomain (public-gprs375156.centertel.pl. [37.47.96.181]) by smtp.gmail.com with ESMTPSA id i8sm34524602wrb.41.2020.04.07.13.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 13:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586290507; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CHs6cxbkTj1ElHA7wXIy9A7gqcG8PwATTttXRLULfSQ=; b=haa7eWEqTAJq5ZsRNmfDtLzdUNlMuYmyC+VX9k8xMF1R6fKdIyxlf72vJiaBP0suxjY5VE DiP6xPCIZccaVB9eMBrEGYGWfr6g+aNlTOae+hnUik+vortPUrCV2egUlRnj+mV9ahsZDg VfY2MdAGnAO2j9ouTLQA4UHszEcAhUI= X-MC-Unique: ph15QPykO6mezgYIRZz1uA-1 X-MC-Unique: ANu-9S75MIyF2pIGDgxXAg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zTwVywNt9gy4JhQgSpfjoQi/UDxXPHMLZTKyDmm7ISQ=; b=DnMi8wSrEl+NfG23khPDyrN8qFJ9KT3K+Z2d6HIlN8EQsLtOO1qiYrKc1FjAHzvbUu XcR37cffn3p+hASZW9m6rHf3oaKkInPxMqHHmn/wwvf/SKfHwYAHx+L0C1euDBj9gfdM 40euyGxmojwmtFtpKt+eo6IB2e/p/JvSqMjsXWW3t66GHSUeXECbPXuzZ/dmzOTs3aOH sLz87dSdYI/hmyeiTD2B1dW+bdEPk6jCa+dCQ5+zWuR2NbinTmbGl1nUBbEQYQnr8eT0 nhBhiGdXCRYNzFz/LhgXQK9oFbyxTWHdJIpcM/h1wJzngrNgaJsXhPMmUSlWV05278MZ jzAg== X-Gm-Message-State: AGi0PuZ3YPc3eFlKFH2g/Yf3TK7sdkuZnENKVjmel4kJLX6fDs/4MBEQ +GvrG4FL6D0PGceRnylg360Xb9+VECY= X-Google-Smtp-Source: APiQypLCz856L49RJ7cGL2RoXj/0qv1ek5kw0Z/+QIgHxxJo5XLHz8wfDGfo74nJg2AUpeLfsF01aQ== X-Received: by 2002:adf:b6ab:: with SMTP id j43mr4534314wre.109.1586290481817; Tue, 07 Apr 2020 13:14:41 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH] util: virdaemon: fix waiting for child processes Date: Tue, 7 Apr 2020 22:14:34 +0200 Message-Id: <20200407201434.1850252-1-r4f4rfs@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 037KEsif013803 X-loop: libvir-list@redhat.com Cc: Rafael Fonseca X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Unlike `waitpid`, `virProcessWait` only returns -1 (error) or 0 (success), so comparing that to `pid` will always be false and the parent will report failure with: error : main:851 : Failed to fork as daemon: No such file or directory even though the grandchild process is succesfully running. Note that the errno message is misleading: it was last set when trying to find a restart state file. Signed-off-by: Rafael Fonseca Reported-by: Marcin Krol Reviewed-by: J=C3=A1n Tomko --- src/util/virdaemon.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/virdaemon.c b/src/util/virdaemon.c index 5d92c7def7..99530fd146 100644 --- a/src/util/virdaemon.c +++ b/src/util/virdaemon.c @@ -97,15 +97,14 @@ virDaemonForkIntoBackground(const char *argv0) default: { /* parent */ - int got, exitstatus =3D 0; + int exitstatus =3D 0; int ret; char status; =20 VIR_FORCE_CLOSE(statuspipe[1]); =20 /* We wait to make sure the first child forked successfully */ - if ((got =3D virProcessWait(pid, &exitstatus, 0)) < 0 || - got !=3D pid || + if (virProcessWait(pid, &exitstatus, 0) < 0 || exitstatus !=3D 0) { goto error; } --=20 2.25.1