[Twisted-Python] _twistd_unix.py / daemonize() / OSX / USING_FORK_WITHOUT_EXEC_IS_NOT_SUPPORTED_BY_FILE_MANAGER

Erik van Blokland erik at letterror.com
Wed Oct 13 10:55:45 EDT 2010


Hi,

I'm running into crashes with deamonize() from _twistd_unix.py on OSX  
10.6 "snow leopard".

Crash report contains the ominous flag:

USING_FORK_WITHOUT_EXEC_IS_NOT_SUPPORTED_BY_FILE_MANAGER

This flag shows up in some issues reported in other python projects on  
OSX. Apparently 10.5 was more forgiving about this but 10.6 aborts the  
process.

- Has this been an issue for twisted users on OSX 10.6?

- Best practices for addressing it?



The code calls fork(), but no exec():

def daemonize():

     # See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16

     if os.fork():   # launch child and...

         os._exit(0) # kill off parent

     os.setsid()

     if os.fork():   # launch child and...

         os._exit(0) # kill off parent again.

     null = os.open('/dev/null', os.O_RDWR)

     for i in range(3):

         try:

             os.dup2(null, i)

         except OSError, e:

             if e.errno != errno.EBADF:

                 raise

     os.close(null)



Thanks,

Erik van Blokland



More information about the Twisted-Python mailing list