How to close all files between fork and exec?
Aahz Maruch
aahz at panix.com
Thu Jan 18 11:23:59 EST 2001
In article <yv27l3t483r.fsf at lionsp093.lion-ag.de>,
Harald Kirsch <kirschh at lionbioscience.com> wrote:
>aahz at panix.com (Aahz Maruch) writes:
>> In article <yv27l3upooj.fsf at lionsp093.lion-ag.de>,
>> Harald Kirsch <kirschh at lionbioscience.com> wrote:
>>>
>>>Python has fork/exec. I want to use it. After fork and before exec I
>>>would like the child process to close all files other than 0, 1 and 2
>>>(i.e. standard input/output/error).
>>
>> Why not simply keep track of all open files in a dict or list?
>
>Thereby duplicating the work the operating system does anyway? And how
>would a module for forking special processes keep track of the files
>opened by the main program calling it? Hmm...
from fork import open
As for your first question, you're always responsible of keeping track
of whatever resources you're using; it's just that sometimes, the
language you're using provides conveniences to make that easier.
--
--- Aahz (Copyright 2001 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
A house is a machine to keep your cat dry. --Aahz
More information about the Python-list
mailing list