From nobody Thu May 16 15:05:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1586348008; cv=none; d=zohomail.com; s=zohoarc; b=CHJ7R/p8RCbKK/AirsHq9ao9NH+0DBM/fWJovm+HnYqurqNur+QpoPrOfV2lKbUuIBUpdhVJl8HbeChsxoYqhbHjkxpDtlrvpg3wDfKe1jCWpMV8CKWUtUt9B/2AUk3sDfctrz/i37KVoa6U8zWXy24VeJeJzRPeDPielSwHyoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586348008; 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=xfOb/Jht+7d7IOl0WqgdFS0TOdRzOzghlBCeiGeCi78=; b=VrCg2w6sPbJEPBA+r8fQC7NQTP5b1+QvEeKUW1MoVJXf+hhwDpwrgamRHcqR8KpdPrqc8q6QZZGUwbQImfEBbOzC2bPiQEei2XFjNV3jjkqo0x97ZZSZ9XeEXMBxr/E2N+gia7HGgbHKcpzEzjhi64rBuxwhiCoqAysaIQ51JkA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158634800834397.87378840716008; Wed, 8 Apr 2020 05:13:28 -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-500-4qpSwHSZOaepOidpwYNi4g-1; Wed, 08 Apr 2020 08:13:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EE178017CE; Wed, 8 Apr 2020 12:13:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 848295C1BB; Wed, 8 Apr 2020 12:13:17 +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 6D44893A85; Wed, 8 Apr 2020 12:13:15 +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 038CDCP8003708 for ; Wed, 8 Apr 2020 08:13:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C50B20230A9; Wed, 8 Apr 2020 12:13:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 885F6202A940 for ; Wed, 8 Apr 2020 12:13:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 52A7C101A55F for ; Wed, 8 Apr 2020 12:13:08 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-TGWhK2YxPnaTv2k88ZMHcg-1; Wed, 08 Apr 2020 08:13:05 -0400 Received: by mail-wr1-f66.google.com with SMTP id p10so7521746wrt.6 for ; Wed, 08 Apr 2020 05:13:03 -0700 (PDT) Received: from localhost.localdomain (public-gprs375156.centertel.pl. [37.47.96.181]) by smtp.gmail.com with ESMTPSA id w18sm12924246wrn.55.2020.04.08.05.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 05:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586348006; 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=xfOb/Jht+7d7IOl0WqgdFS0TOdRzOzghlBCeiGeCi78=; b=AzarA+leRDC3YXt8kb5KPXIuUzojIE+HDZWqN8TTc6Huc2rFyPJ+Ez6405aBeLPs7UBA46 YT+y0f287kNk8MTAgRJR1Ge2qni6YR8nkF0dsDHnQjQrQAwc5Hoi+rcc8a510n8nEzhlJa +/8AKPn/f8jq1t55uVyqFeSiFPOBYzA= X-MC-Unique: 4qpSwHSZOaepOidpwYNi4g-1 X-MC-Unique: TGWhK2YxPnaTv2k88ZMHcg-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=4wduMXWsIar4V3emAlwCpIWLSVXgkAEh9HXDW6O3mWA=; b=GV6F6HCFzuVsOTvUwjc06gZzmPb0QfiIo+9eSEUy059pkdXwfRqPHn6AJJduyYhh2R ED5SpX/db9DWvwIlX1j8AwE1q1Ou7bNwu3sj2LuQp1N5SDdTzwr4MFSMS5vgnT3a88DX ycL2u7cu/SsxiBuBliZ4tlViAYU/L4ua1BNkrUtpvk2mL2++HGl1X8+Aym5t9nxPj4DH 81ZeFApMV85xFI8Vg0iJpNCboQEg9sZU6bLPiRX0M7mjeAoAhYpb3T//LIdGpH01VA1s 45t8MeaioWs8uvLABiDfOiAkLZHtm9V/xOHWi5MwuFnO18sp+m5Xu8qxCJo2hzxdE4qr RbxA== X-Gm-Message-State: AGi0PubQk0AeYyjaWHRqQjuZC3Z+hikJ5fbZJqNoJ1hMJD2xVK6k3AWW KR8Jy40zLhIdaGott6TQsB/XKKCA8Ww= X-Google-Smtp-Source: APiQypJ3n8jETsq5XZmOHPwdxIE2qINu65feHPPLPaglM4t+Vi4pv/6/C+EDjP8nY+J0aZ2pN1pTFQ== X-Received: by 2002:adf:f091:: with SMTP id n17mr3777203wro.404.1586347982036; Wed, 08 Apr 2020 05:13:02 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH v2] util: virdaemon: fix waiting for child processes Date: Wed, 8 Apr 2020 14:12:54 +0200 Message-Id: <20200408121254.1875641-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 038CDCP8003708 X-loop: libvir-list@redhat.com Cc: Rafael Fonseca , Marcin Krol 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.16 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.2