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. Victor 2013/7/25 Eric V. Smith <e...@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. > > -- > Eric. > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com