From nobody Tue Feb 10 16:22:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611937056; cv=none; d=zohomail.com; s=zohoarc; b=lMtNnYeT84A2aWFbMv5149qw72gvcfllxeRWjIyLFF2RrvrbRrD8pMkxurbZaElNkh7k1bJ2cIjn6T67fU9oZBU4sh0mpRQciRpEuL/Xshk30jn0FkpPViLRg7BK6oPBv0+0qdB/md3wRuGRYS9HuHNGMCJdZUjZDZUKilSlRXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611937056; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FERoLacJ+OYH6c0/PcnZKG7/HFadbJ1Z1c/3FZDZjwc=; b=Xg1Bd7gx+Rp0iHjZr1u+sxAWlJ6qVsq9Yf7KgedxoYz/gMArivf2YTf+4Ci1BCCc5rVBqDKxNcJPV4JZxXXHtM9LZ4dx1+VSQ2la0nU7zpyus8awmQko3HUxovK2L/2844vfQg/Amp+5z8WtS5snyl5CH9yWhMr/YlzPEFmGMVI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1611937056933995.7263969117656; Fri, 29 Jan 2021 08:17:36 -0800 (PST) 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-131-saeghY0bMHyLnc_FdLkjlQ-1; Fri, 29 Jan 2021 11:17:32 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A4C280F044; Fri, 29 Jan 2021 16:17:25 +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 EDA6C60CD0; Fri, 29 Jan 2021 16:17:24 +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 B5B9A50043; Fri, 29 Jan 2021 16:17:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10TGHLn9010632 for ; Fri, 29 Jan 2021 11:17:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id D15C260CC4; Fri, 29 Jan 2021 16:17:21 +0000 (UTC) Received: from work.redhat.com (ovpn-113-143.ams2.redhat.com [10.36.113.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F6A660871; Fri, 29 Jan 2021 16:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611937055; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FERoLacJ+OYH6c0/PcnZKG7/HFadbJ1Z1c/3FZDZjwc=; b=ZvLR6rTm2WM3fqoozsW+oUMSly5bbNcfkW41uFsNEy9MeKYrFH2cxaxoYo8uXcCquFD3IQ CbSx/OoCo787DAVsqHbX4bxapFDaSTG79dQm7Gd0ifoyHkBDoIfTdVqtL1hVoBLGIBpe3p 55BPAjzg9AdHmFYW4IjtK4Rruwt0UiE= X-MC-Unique: saeghY0bMHyLnc_FdLkjlQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 11/19] commandhelper: Factor out printDaemonization Date: Fri, 29 Jan 2021 17:16:21 +0100 Message-Id: <20210129161629.604823-12-twiederh@redhat.com> In-Reply-To: <20210129161629.604823-1-twiederh@redhat.com> References: <20210129161629.604823-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Signed-off-by: Tim Wiederhake --- tests/commandhelper.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index fa32f6a435..01dd6f9e45 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -153,6 +153,19 @@ static int printFds(FILE *log) return 0; } =20 +static void printDaemonization(FILE *log, struct Arguments *args) +{ + int retries =3D 3; + + if (args->daemonize_check) { + while ((getpgrp() =3D=3D getppid()) && (retries-- > 0)) { + usleep(100 * 1000); + } + } + + fprintf(log, "DAEMON:%s\n", getpgrp() !=3D getppid() ? "yes" : "no"); +} + int main(int argc, char **argv) { struct Arguments *args =3D parseArguments(argc, argv); size_t i; @@ -162,7 +175,6 @@ int main(int argc, char **argv) { struct pollfd fds[3]; char *buffers[3] =3D {NULL, NULL, NULL}; size_t buflen[3] =3D {0, 0, 0}; - size_t daemonize_retries =3D 3; char buf[1024]; ssize_t got; =20 @@ -177,17 +189,7 @@ int main(int argc, char **argv) { if (printFds(log) !=3D 0) goto cleanup; =20 - while (true) { - bool daemonized =3D getpgrp() !=3D getppid(); - - if (args->daemonize_check && !daemonized && daemonize_retries-- > = 0) { - usleep(100*1000); - continue; - } - - fprintf(log, "DAEMON:%s\n", daemonized ? "yes" : "no"); - break; - } + printDaemonization(log, args); =20 if (!(cwd =3D getcwd(NULL, 0))) goto cleanup; --=20 2.26.2