How to close all files between fork and exec?

Erno Kuusela erno-news at erno.iki.fi
Wed Jan 17 12:33:36 EST 2001


In article <yv27l3upooj.fsf at lionsp093.lion-ag.de>, Harald Kirsch
<kirschh at lionbioscience.com> writes:

| On some systems there is a constant like OPEN_MAX but I read that on
| recent Solaris versions there is no real limit to it.
| How do I get hold of the highest numbered open file descriptor, in
| particular in python?

a reasonable heuristic might be to try closing from 0 ... n
and break the loop when you've hit m EBADF errors in a row
(m=500?)

some systems have nonportable ways of finding out the open
fd numbers, like /proc/<pid>/fd/ in linux.

  -- erno



More information about the Python-list mailing list