Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90855
| References | <CANc-5UyeaWqThGFSAuGskz+S2Lrgq0ia9W9DHAie28t9GY+sww@mail.gmail.com> <CAPTjJmoj4STV9+t2-9JWed3t6Hxk5ibtaxYSFfX31oGz=kKR1g@mail.gmail.com> <CANc-5UwUxYjg=rQQ0Z_nM3s7o4+ghVYzG-9ajQY=LERWAsPrKw@mail.gmail.com> |
|---|---|
| Date | 2015-05-19 23:54 +1000 |
| Subject | Re: fork/exec & close file descriptors |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.137.1432043685.17265.python-list@python.org> (permalink) |
On Tue, May 19, 2015 at 11:44 PM, Skip Montanaro <skip.montanaro@gmail.com> wrote: > > On Tue, May 19, 2015 at 8:33 AM, Chris Angelico <rosuav@gmail.com> wrote: >> >> What Python version are you targeting? Are you aware of PEP 446? > > > Yeah, I'm still on 2.7, and am aware of PEP 446. Note that many of the file > descriptors will not have been created by my Python code. They will have > been created by underlying C/C++ libraries, so I can't guarantee which flags > were set on file open. > > I'm going to continue to pursue solutions which won't require a restart for > now, but would like to have a sane restart option in my back pocket should > it become necessary. Fair enough. What you MAY be able to do is preempt it by going through your FDs and setting them all CLOEXEC, but it won't make a lot of difference compared to just going through them all and closing them between fork and exec. On Linux (and possibly some other Unixes), /proc/self/fd may be of use. Enumerating files in that should tell you about your open files. How useful that is I don't know, though. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: fork/exec & close file descriptors Chris Angelico <rosuav@gmail.com> - 2015-05-19 23:54 +1000
csiph-web