[DFD] daemonization problems solved

travis+ml-dfd at subspacefield.org travis+ml-dfd at subspacefield.org
Thu Jun 25 17:01:21 CDT 2009


So I dug deeper into why dfd_keeper scripts died if they tried to
close all their open file descriptors.

I ran it under ktrace and discovered the following:

It appears that the python interpreter likes to have file handles open
to a variety of files:

fd 3 is used to load various shared libraries but is closed after each use
fd 5 is my keeper_screen script, which implements my firewall
fd 6 is /usr/local/lib/python2.5/site.py
fd 7 is /usr/local/lib/python2.5/site.pyc and /usr/local/lib/python2.5/os.py
fd 8 is /usr/local/lib/python2.5/os.pyc and /usr/local/lib/python2.5/posixpath.py
fd 9 is /usr/local/lib/python2.5/posixpath.pyc and /usr/local/lib/python2.5/stat.py
fd 10 is /usr/local/lib/python2.5/stat.pyc

fds 8,9, and 10 are closed after use.

So that explains why I was able to close file descriptors over 7 with
no problems, but trying to close all file descriptors caused DFD to
give python exceptions.

It appears that every python module you load is opened with a file
descriptor to its uncompiled representation which is left open, and
another file descriptor is used to load the .pyc but is closed after
use.

I guess I'll close file descriptors 0 through 2 and just leave the rest
of them as python desires them.
-- 
Obama Nation | My emails do not have attachments; it's a digital signature
that your mail program doesn't understand. | http://www.subspacefield.org/~travis/ 
If you are a spammer, please email john at subspacefield.org to get blacklisted.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
Url : http://lists.bitrot.info/pipermail/dfd/attachments/20090625/ff653262/attachment.pgp 


More information about the DFD mailing list