From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by sourceware.org (Postfix) with ESMTPS id 6061D394800A for ; Mon, 5 Dec 2022 18:55:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6061D394800A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=owlfolio.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=owlfolio.org Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 5FBAD320097A for ; Mon, 5 Dec 2022 13:55:39 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 05 Dec 2022 13:55:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owlfolio.org; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1670266538; x= 1670352938; bh=Kj+Y7Rkv36VHnwZrDqFa193gmIDuwdMBPAE5VgaLGGI=; b=x 9xYNEcN3wWSH+9X1cnsyAznU9W1ZIkUPISrm9+H5obF5gosoofxD6akpt4Q/zMnJ pLvDkxvXMuTOZAf94B2a67jdzdIikW6EV+uk0LqS3KMKv8xuoMNj51f/nitf0ySF 3S2ui0hMNZwxNka4UfY0qTMYADsWiSOfAQyOWOe/PMFI7VFGlsS05Au/o9L0X5cl wbdQVkfLDcAmxzrLnDjVauBdISNGxi+EarmhnhmAldd0b4e7PoojsKdKPLAySBWd oPSu0wsbW7uWHbWyn3eVBzGghBBBpYbTk0R4FPVLcFXAI5Qhusgq/k3IHMr3E8gj IYNz+Uwr+7nTfys06jsgA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1670266538; x=1670352938; bh=K j+Y7Rkv36VHnwZrDqFa193gmIDuwdMBPAE5VgaLGGI=; b=E6XSf/YSK2fAX2hPJ SPxv78BXGFkZxJrhxHVBue+fyJLnq05/ePROTDblSQqgEpx2bJY7Pb34OHIWZQ4i 7tkD6wJv3k9/2Mp30cQ6LNx1Y/ad5Sec5n2cYE0Y6Z1IiIjlF6vmW8S1opDhqOvm kGvnrOEytItU9vfnber4W5w9t8wS4xfMyzkQnd/Q4xsxlLP9laWg7BHD2NmhRy5c /ADJJt74eNXFB0YgfA5BEbo3s1vQ8pLOwOBGqFpf9Lqw/D56ncWSJiCCj3EMplP6 wtj77XQgbXoLH3ekaP806nCly5dIVv16ov+JR5HTKWp/cEN7eKtiLWkIn5iHxVKf O5ofQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeggdduudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtje ertddtfeejnecuhfhrohhmpegkrggtkhcuhggvihhnsggvrhhguceoiigrtghksehofihl fhholhhiohdrohhrgheqnecuggftrfgrthhtvghrnhepgedvueegveefudfhvdffudejhf fgleektdduvdeffedvueeuhfduiefgtdevjeefnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomhepiigrtghksehofihlfhholhhiohdrohhrgh X-ME-Proxy: Feedback-ID: i876146a2:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 5 Dec 2022 13:55:38 -0500 (EST) Message-ID: <83b50ed9-9391-2413-6375-fe5e4650d169@owlfolio.org> Date: Mon, 5 Dec 2022 13:55:38 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: Resource use fopen-vs-freopen Content-Language: en-US To: libc-alpha@sourceware.org References: <08776f09871ef817669410c7b1a26122e3c2c75b.camel@gentoo.org> From: Zack Weinberg In-Reply-To: <08776f09871ef817669410c7b1a26122e3c2c75b.camel@gentoo.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,JMQ_SPF_NEUTRAL,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP 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: On 2022-12-04 4:34 PM, David Seifert via Libc-alpha wrote: ... > void reset_std_streams(void) { > stdin = fopen("/dev/null", "r"); > } ... > void reset_std_streams(void) { > freopen("/dev/null", "r", stdin); > } ... > When comparing the total tally of all resources used at point A in > snippet 1 and point B in snippet 2, is there an actual difference? Yes. Snippet 1 leaks the old FILE object and, critically, *does not change file descriptor 0*, which remains open on the old stdin. zw