Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'context': 0.05; 'one?': 0.05; 'redirected': 0.07; 'subject:file': 0.07; 'alain': 0.09; 'received:internal': 0.09; 'wed,': 0.15; '"some': 0.16; '(e.g.)': 0.16; 'descriptors': 0.16; 'library"': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'wrote:': 0.16; 'library': 0.20; 'header:In-Reply-To:1': 0.24; 'this.': 0.28; 'subject:/': 0.29; 'generally': 0.32; 'ordered': 0.33; 'file': 0.34; 'useful': 0.35; 'to:addr:python-list': 0.35; "isn't": 0.35; 'closing': 0.36; 'received:10': 0.37; 'subject:: ': 0.37; 'received:66': 0.38; 'mean': 0.38; 'thank': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'back': 0.61; 'close': 0.61; 'from:no real name:2**0': 0.61; "you've": 0.61; 'header:Message-Id:1': 0.62; 'within': 0.64; 'subject: & ': 0.73; 'ranges': 0.76; 'absolutely': 0.87 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=SbZn2OWArgDt6fqLsJrJF9xUc64=; b=GvKyCO bTE3r2/wSBjqz8dgAFRmuqQkfiOXttSCSUdnnKCJWt5Z5RS4zPjRXECcGREVGpPV xwp0P4+MGj9EXb9x8Tr8Ili5HZK22JUr3I9btZx+VA+PAF3Fram1v6NqNq2krK9O CAueMup40XoNMFyXv7l+SyzP+PFRDv1zNWU4Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=SbZn2OWArgDt6fq LsJrJF9xUc64=; b=MzFRBuJi9644kPlZZFJU7VIjKHsNP9d+8aoLuPdJUvv0Zdo 0EzJfmJV19xbJAaA6N+ngzvOfzviCLNqu6kT+bcOwKWRcQMJPqKvOAA8PQGZapuW 6z7Idm85zYwdQmuE26vh60n7CI0XLaGDDmjed/EH56DsmkevLTzhMljzFV5c= X-Sasl-Enc: K+0UvQNoh3quh0OY9RnF9sb4WNGZ0oT8vnnHUVV6qCnd 1433334069 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-073992ec Subject: Re: fork/exec & close file descriptors Date: Wed, 03 Jun 2015 08:21:09 -0400 In-Reply-To: <87h9qpl10o.fsf@universite-de-strasbourg.fr.invalid> References: <87pp5eksnc.fsf@universite-de-strasbourg.fr.invalid> <87eglt7u5i.fsf@elektro.pacujo.net> <87lhg1lt00.fsf@universite-de-strasbourg.fr.invalid> <87h9qpl10o.fsf@universite-de-strasbourg.fr.invalid> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433334072 news.xs4all.nl 2896 [2001:888:2000:d::a6]:59830 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91950 On Wed, Jun 3, 2015, at 03:11, Alain Ketterlin wrote: > Thank you, I know this. What I mean is: what are the reasons that you > cannot access your file descriptors one by one? To me closing a range of > descriptors has absolutely no meaning, simply because ranges have no > meaning for file descriptors (they're not ordered in any way). What if > some library uses its own descriptors that happen to lie in your > "range"? Etc. The context in which this is useful is that you've just forked, and you're about to exec. "Some library" isn't going to ever get back control within the current process. Generally the range of file descriptors you want to close is (e.g.) 3-Infinity, after you've already got 0 1 and 2 pointing to where you want them (whatever redirected file or pipe).