Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'heavily': 0.04; 'subject:file': 0.07; 'command.': 0.09; 'received:internal': 0.09; 'spawn': 0.09; 'wed,': 0.15; '(more': 0.16; 'command,': 0.16; 'descriptors.': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'reason.': 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; 'slice.': 0.16; 'ui,': 0.16; 'wrote:': 0.16; "shouldn't": 0.18; 'shell': 0.18; "user's": 0.22; 'file.': 0.24; 'header:In-Reply- To:1': 0.24; 'chris': 0.26; 'subject:/': 0.29; 'itself,': 0.29; 'parent': 0.29; 'run': 0.32; "can't": 0.32; 'system,': 0.32; 'holds': 0.32; 'lets': 0.33; 'open': 0.33; 'editor': 0.34; 'file': 0.34; 'to:addr:python-list': 0.35; 'done': 0.35; 'something': 0.35; 'really': 0.35; 'being': 0.36; 'text': 0.36; 'there': 0.36; 'child': 0.36; 'closing': 0.36; 'loaded': 0.36; 'should': 0.37; 'received:10': 0.37; 'subject:: ': 0.37; "won't": 0.38; 'received:66': 0.38; 'whatever': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'close': 0.61; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.62; 'waiting': 0.63; 'results': 0.66; 'fact,': 0.67; 'subject: & ': 0.73; 'instantly': 0.93 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=CstX9/ufzPWhzfuogtxXz5ndZHk=; b=BJkU8x O4t9ALgGUJWHgU6Yg31XwLcoJWG3CyHZOEwVLOExtnVnvHIJdW7Jt0+HFlrDDxCU 0R+FYCKKE0sAukuVWp8i45hLMFSDHbfsPZ3kawcEyPG2h7AFHa7RPWqZ90aXmMgA YIfCD/OCMfHLNKJUtRRX+hPaJEEYuJ6IV1aRI= 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=CstX9/ufzPWhzfu ogtxXz5ndZHk=; b=CIrynwavnLVt8QdhuNEBBUOuqGBZYY82iYSpVzC6yp01EIf D3zE5W+ZLimYtY/POGiOoWmKps5Htk3iCaNaeCceA3et8vwMMPZXT6cpBHNAMHGB f0S+LrU2BcUnkDqnP4SDHtTURSheHt6HvwijlOf0N+kFP3wrGebaiC5J1kWY= X-Sasl-Enc: GGv08S0aZvMURZkrJlR4QLcvJrelQGN8Df7GbwRJM0qG 1433362046 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 In-Reply-To: References: <87pp5eksnc.fsf@universite-de-strasbourg.fr.invalid> <87eglt7u5i.fsf@elektro.pacujo.net> <87lhg1lt00.fsf@universite-de-strasbourg.fr.invalid> <87a8wh7nq6.fsf@elektro.pacujo.net> <87d21dl0jc.fsf@universite-de-strasbourg.fr.invalid> <877frl6xxj.fsf@elektro.pacujo.net> <556eee15$0$12975$c3e8da3$5496439d@news.astraweb.com> <878uc1567j.fsf@elektro.pacujo.net> <87wpzl3pnn.fsf@elektro.pacujo.net> <1433337679.1493926.285725793.69D6B33F@webmail.messagingengine.com> Subject: Re: fork/exec & close file descriptors Date: Wed, 03 Jun 2015 16:07:26 -0400 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433362050 news.xs4all.nl 2842 [2001:888:2000:d::a6]:59215 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91989 On Wed, Jun 3, 2015, at 09:32, Chris Angelico wrote: > Write an editor that opens a file and holds it open until the user's > done with it. Have something that lets you shell out for whatever > reason. Then trigger the shell-out, and instantly SIGSTOP the child > process, before it does its work - or just have a really heavily > loaded system, so it can't get a time slice. Now close the file in the > UI, which results in the file being closed in the parent. Right, now > let the child run... and there it goes, closing the file. The parent should be waiting for the child process. If it shouldn't wait for the command, then the child process should spawn a grandchild process, after closing the file descriptors. This is how the text editor I use actually works (more or less. In fact, the way to run a process it won't wait for is to run it as a background shell command. If you STOP the shell itself, the editor will be stuck waiting.)