[Python-Dev] Inherance of file descriptor and handles on Windows (PEP 446)
victor.stinner at gmail.com
Mon Aug 5 14:52:25 CEST 2013
I checked the python-daemon module: it closes all open file
descriptors except 0, 1, 2. It has a files_preserve attribute to keep
some FD opens. It redirects stdin, stdout and stderr to /dev/null and
keep these file descriptors open. If python-daemon is used to execute
a new program, the files_preserve list can be used to mark these file
descriptors as inherited.
The zdaemon.zdrun module closes all open file descriptors except 0, 1,
2. It uses also dup2() to redirect stdout and stderr to the write end
of a pipe.
2013/7/25 Eric V. Smith <eric at trueblade.com>:
> On 7/24/2013 6:25 PM, Guido van Rossum wrote:
>>>> To reduce the need for 3rd party subprocess creation code, we should
>>>> have better daemon creation code in the stdlib -- I wrote some damn
>>>> robust code for this purpose in my previous job, but it never saw the
>>>> light of day.
>>> What do you call "daemon"? An actual Unix-like daemon?
>> Yeah, a background process with parent PID 1 and not associated with
>> any terminal group.
> There's PEP 3143 and https://pypi.python.org/pypi/python-daemon. I've
> used it often, with great success.
> Python-Dev mailing list
> Python-Dev at python.org
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
More information about the Python-Dev