On Sun, 20 Jun 2010 20:00:14 +1000, Ben Finney wrote: >> I'm starting a SocketServer.TCPServer in my program, but since I want >> to report problems to script starting the program, I want to go daemon >> *after* TCPServer has done binding to port. >> >> Is this likely to cause problems? I mean, my client works when I do >> the above, that is, it connects to the server. But I'm not sure if >> above is the Right Thing(tm). > > There is more to becoming a well-behaved daeon process than merely > detaching the process. For details, see PEP 3143 “Standard daemon > process library” <URL:http://www.python.org/dev/peps/pep-3143/>.
The OP's code does most of what the Linux/BSD daemon() call does, except that it doesn't close or replace inherited descriptors. Many of the recommendations in PEP 3143 are "optional extras". The main "requirement" which cannot reasonably be encapsulated into a daemon() procedure is to avoid subsequently acquiring a controlling terminal (by passing O_NOCTTY to all open() calls). Even if Python was to integrate this into open() (and similar), there's no guarantee that libraries used via extension modules or ctypes will do likewise. -- http://mail.python.org/mailman/listinfo/python-list