From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A697A1F8C6 for ; Tue, 3 Aug 2021 15:25:37 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B7F03955425 for ; Tue, 3 Aug 2021 15:25:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B7F03955425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628004336; bh=LJq4h+7adcwrWhrulzeDUQHXTd8Hhfzu/CrN4rir6tA=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PGnkP0+7dgkROPTqEJAbIHrJmF0iz92EnS8EZyFFuZQBps7MlOM0fkgcfV4R2/7iC hiAnc6UyLHWbFBU/n7Bt+0y7rsW/CKmVTvSozIEZK7jB1Z6SRV8zK7+M3oaTcxWZdZ RPVnLM/hj0XYvgHbfrw4UQDxcooLByAzkTyq6Ub8= Received: from anamika.lostca.se (anamika.lostca.se [IPv6:2a01:4f9:3b:505c::2]) by sourceware.org (Postfix) with ESMTPS id E63DF3851C14; Tue, 3 Aug 2021 15:25:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E63DF3851C14 Received: from localhost (mail.lostca.se [65.21.75.227]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: spectre) by anamika.lostca.se (Postfix) with ESMTPSA id 9C0371B918; Tue, 3 Aug 2021 15:25:15 +0000 (UTC) Date: Tue, 3 Aug 2021 15:25:15 +0000 To: Siddhesh Poyarekar Subject: Re: [PATCH 4/5] copy_and_spawn_sgid: Avoid double calls to close() Message-ID: <20210803152515.GD6986@lostca.se> References: <20210727174129.3612656-1-siddhesh@sourceware.org> <20210727174129.3612656-5-siddhesh@sourceware.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210727174129.3612656-5-siddhesh@sourceware.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Arjun Shankar via Libc-alpha Reply-To: Arjun Shankar Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Hi Siddhesh, > If close() on infd and outfd succeeded, reset the fd numbers so that > we don't attempt to close them again. > --- > support/support_capture_subprocess.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c > index 27bfd19c93..0bacf6dbc2 100644 > --- a/support/support_capture_subprocess.c > +++ b/support/support_capture_subprocess.c > @@ -170,6 +170,7 @@ copy_and_spawn_sgid (char *child_id, gid_t gid) > support_subprogram because we only want the program exit status, not the > contents. */ > ret = 0; > + infd = outfd = -1; > > char * const args[] = {execname, child_id, NULL}; Looks good to me. infd and outfd are indeed close'd above, and close'd again below if they are non-negative. Setting to -1 ensures that we won't attempt to close them again. Reviewed-by: Arjun Shankar Cheers!