From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 670003858CDB for ; Sat, 22 Apr 2023 11:48:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 670003858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqBil-0006XW-Em; Sat, 22 Apr 2023 07:48:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=5UzKPUIKHSDwNIHvkSSsbJxiWm/VAZl8te1qkAsi6ks=; b=djfEZu/JElI6M+/WjQLx wzqXsSOnAgAxGnz0St7Fd0vFCs8n+TwXTXvBZ5XIJxT4u27URolbWfvkfdEBQEtB2gxv4nEtqZREA jzdMlDN40KSdzlctOyNiv3JiR2reqvHSR0NkOOxfMM7YAzWPU4ZuI4n9/Z/5g850p8DD81gnmyRW2 /sOTX6JObMwAWqQKMv/jUMc7+ZhM8r2ZX+uqe5huNm62oMFlrmR5H1SduFNMoAyRuZUHaEdfXMoMt 3HrZxWjgk6QZFVMbWKFutEIKHzbZLKgccLk8fiN8xQnAVIlDlnDOphKoGTGuoLOvtXBGf5D+RouTu We1m/frjvT91oQ==; Received: from [2a01:cb19:4a:a400:de41:a9ff:fe47:ec49] (helo=begin.home) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqBij-0005QR-Mt; Sat, 22 Apr 2023 07:48:02 -0400 Received: from samy by begin.home with local (Exim 4.96) (envelope-from ) id 1pqBih-0068zT-23; Sat, 22 Apr 2023 13:47:59 +0200 Date: Sat, 22 Apr 2023 13:47:59 +0200 From: Samuel Thibault To: Adhemerval Zanella Netto Cc: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org, Cristian =?utf-8?Q?Rodr=C3=ADguez?= Subject: Re: [RFC PATCH v2 1/7] misc: Convert daemon () to GNU coding style Message-ID: <20230422114759.7567si453xkzdist@begin> Mail-Followup-To: Adhemerval Zanella Netto , Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org, Cristian =?utf-8?Q?Rodr=C3=ADguez?= References: <20230419160207.65988-1-bugaevc@gmail.com> <20230419160207.65988-2-bugaevc@gmail.com> <1d9ec490-65e2-0756-790f-78e4e6df75d9@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1d9ec490-65e2-0756-790f-78e4e6df75d9@linaro.org> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Applied, thanks! Adhemerval Zanella Netto, le ven. 21 avril 2023 09:18:19 -0300, a ecrit: > > > On 19/04/23 13:02, Sergey Bugaev wrote: > > This is nicer, and is going to be required for the following changes > > to reasonably stay within the 79 column limit. > > > > No functional change. > > > > Signed-off-by: Sergey Bugaev > > LGTM, thanks. I can be installed independently. > > Reviewed-by: Adhemerval Zanella > > > --- > > misc/daemon.c | 88 ++++++++++++++++++++++++++++----------------------- > > 1 file changed, 49 insertions(+), 39 deletions(-) > > > > diff --git a/misc/daemon.c b/misc/daemon.c > > index 3c73ac2a..14577e40 100644 > > --- a/misc/daemon.c > > +++ b/misc/daemon.c > > @@ -43,50 +43,60 @@ static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93"; > > int > > daemon (int nochdir, int noclose) > > { > > - int fd; > > + int fd; > > > > - switch (__fork()) { > > - case -1: > > - return (-1); > > - case 0: > > - break; > > - default: > > - _exit(0); > > - } > > + switch (__fork ()) > > + { > > + case -1: > > + return -1; > > > > - if (__setsid() == -1) > > - return (-1); > > + case 0: > > + break; > > > > - if (!nochdir) > > - (void)__chdir("/"); > > + default: > > + _exit (0); > > + } > > > > - if (!noclose) { > > - struct __stat64_t64 st; > > + if (__setsid () == -1) > > + return -1; > > > > - if ((fd = __open_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1 > > - && __glibc_likely (__fstat64_time64 (fd, &st) == 0)) { > > - if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0 > > + if (!nochdir) > > + (void) __chdir ("/"); > > + > > + if (!noclose) > > + { > > + struct __stat64_t64 st; > > + > > + fd = __open_nocancel (_PATH_DEVNULL, O_RDWR, 0); > > + if (fd != -1 && __glibc_likely (__fstat64_time64 (fd, &st) == 0)) > > + { > > + if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0 > > #if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR > > - && (st.st_rdev > > - == makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR)) > > + && (st.st_rdev == makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR)) > > #endif > > - ) { > > - (void)__dup2(fd, STDIN_FILENO); > > - (void)__dup2(fd, STDOUT_FILENO); > > - (void)__dup2(fd, STDERR_FILENO); > > - if (fd > 2) > > - (void)__close (fd); > > - } else { > > - /* We must set an errno value since no > > - function call actually failed. */ > > - __close_nocancel_nostatus (fd); > > - __set_errno (ENODEV); > > - return -1; > > - } > > - } else { > > - __close_nocancel_nostatus (fd); > > - return -1; > > - } > > - } > > - return (0); > > + ) > > + { > > + (void) __dup2 (fd, STDIN_FILENO); > > + (void) __dup2 (fd, STDOUT_FILENO); > > + (void) __dup2 (fd, STDERR_FILENO); > > + if (fd > 2) > > + (void) __close (fd); > > + } > > + else > > + { > > + /* We must set an errno value since no function call > > + actually failed. */ > > + __close_nocancel_nostatus (fd); > > + __set_errno (ENODEV); > > + return -1; > > + } > > + } > > + else > > + { > > + __close_nocancel_nostatus (fd); > > + return -1; > > + } > > + } > > + > > + return 0; > > } > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.