How to close all files between fork and exec?

Harald Kirsch kirschh at lionbioscience.com
Thu Jan 18 02:44:56 EST 2001


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...

  Harald Kirsch.
-- 
----------------+------------------------------------------------------
Harald Kirsch   | kirschh at lionbioscience.com | "How old is the epsilon?"
LION Bioscience | +49 6221 4038 172          |        -- Paul Erdös
       *** Please do not send me copies of your posts. ***



More information about the Python-list mailing list