Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91963
| References | (9 earlier) <556eee15$0$12975$c3e8da3$5496439d@news.astraweb.com> <878uc1567j.fsf@elektro.pacujo.net> <mailman.104.1433336055.13271.python-list@python.org> <87wpzl3pnn.fsf@elektro.pacujo.net> <1433337679.1493926.285725793.69D6B33F@webmail.messagingengine.com> |
|---|---|
| Date | 2015-06-03 23:32 +1000 |
| Subject | Re: fork/exec & close file descriptors |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.109.1433338346.13271.python-list@python.org> (permalink) |
On Wed, Jun 3, 2015 at 11:21 PM, <random832@fastmail.us> wrote: > On Wed, Jun 3, 2015, at 09:08, Marko Rauhamaa wrote: >> random832@fastmail.us: >> >> > Why does the child process need to report the error at all? The parent >> > process will find out naturally when *it* tries to close the same file >> > descriptor. >> >> That's not how it goes. >> >> File descriptors are reference counted in the Linux kernel. Closes are >> no-ops except for the last one that brings the reference count to zero. >> >> If the parent should close the file before the child, no error is >> returned to the parent. > > Why would the parent close it before the child? Your scenario doesn't > seem to have anything to do with how people actually use subprocesses. 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. Mightn't be a common situation (given that the amount of code executed between forking and closing FDs is not going to be much, and isn't going to involve reading from disk or anything), but it can certainly happen. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: fork/exec & close file descriptors Skip Montanaro <skip.montanaro@gmail.com> - 2015-06-02 08:58 -0500
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-02 18:28 +0300
Re: fork/exec & close file descriptors Skip Montanaro <skip.montanaro@gmail.com> - 2015-06-02 10:42 -0500
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-02 19:24 +0300
Re: fork/exec & close file descriptors Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-06-02 16:37 +0000
Re: fork/exec & close file descriptors MrJean1 <MrJean1@gmail.com> - 2015-06-12 13:43 -0700
Re: fork/exec & close file descriptors Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2015-06-02 17:59 +0200
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-02 23:05 +0300
Re: fork/exec & close file descriptors Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2015-06-02 23:06 +0200
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 01:24 +0300
Re: fork/exec & close file descriptors Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2015-06-03 09:21 +0200
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 10:41 +0300
Re: fork/exec & close file descriptors alister <alister.nospam.ware@ntlworld.com> - 2015-06-03 09:38 +0000
Re: fork/exec & close file descriptors Steven D'Aprano <steve@pearwood.info> - 2015-06-03 22:07 +1000
Re: fork/exec & close file descriptors alister <alister.nospam.ware@ntlworld.com> - 2015-06-03 12:18 +0000
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 15:27 +0300
Re: fork/exec & close file descriptors alister <alister.nospam.ware@ntlworld.com> - 2015-06-03 13:05 +0000
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 17:49 +0300
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 15:25 +0300
Re: fork/exec & close file descriptors random832@fastmail.us - 2015-06-03 08:54 -0400
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 16:08 +0300
Re: fork/exec & close file descriptors random832@fastmail.us - 2015-06-03 09:21 -0400
Re: fork/exec & close file descriptors Chris Angelico <rosuav@gmail.com> - 2015-06-03 23:32 +1000
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 16:33 +0300
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 17:43 +0300
Re: fork/exec & close file descriptors random832@fastmail.us - 2015-06-03 16:08 -0400
Re: fork/exec & close file descriptors Marko Rauhamaa <marko@pacujo.net> - 2015-06-04 00:09 +0300
Re: fork/exec & close file descriptors random832@fastmail.us - 2015-06-03 16:07 -0400
Re: fork/exec & close file descriptors Chris Angelico <rosuav@gmail.com> - 2015-06-04 07:54 +1000
Re: fork/exec & close file descriptors Chris Angelico <rosuav@gmail.com> - 2015-06-03 09:54 +1000
Re: fork/exec & close file descriptors Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2015-06-03 09:11 +0200
Re: fork/exec & close file descriptors random832@fastmail.us - 2015-06-03 08:21 -0400
Re: fork/exec & close file descriptors Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2015-06-03 15:16 +0200
Re: fork/exec & close file descriptors Skip Montanaro <skip.montanaro@gmail.com> - 2015-06-02 20:21 -0500
csiph-web