From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21199 invoked from network); 18 Dec 2021 17:14:31 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 18 Dec 2021 17:14:31 -0000 Received: (qmail 26533 invoked by uid 550); 18 Dec 2021 17:14:29 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26498 invoked from network); 18 Dec 2021 17:14:28 -0000 Date: Sat, 18 Dec 2021 12:14:15 -0500 From: Rich Felker To: Markus Wichmann Cc: musl@lists.openwall.com Message-ID: <20211218171414.GO7074@brightrain.aerifal.cx> References: <20211218163320.GA1950@voyager> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211218163320.GA1950@voyager> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Feasibility of FD_CLOEXEC on all streams On Sat, Dec 18, 2021 at 05:33:20PM +0100, Markus Wichmann wrote: > Hi all, > > I was recently reading the source code of popen(), and noticed that it > has to iterate over all open files to close all the open pipe FDs the > child might inherit. And that made me wonder: > > 1. Does POSIX allow for all FILE streams to have FD_CLOEXEC applied by > default? No. Accessing fileno(f) is permissible subject to following the rules for active handle: https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_05_01 and that entails being able to use them according to the rules for how fds are inherited across exec. Rich