the dreaded double fork
Дамјан Георгиевски
me at here.there.nowhere
Thu May 6 08:26:42 EDT 2004
> I am using python to run an xml rpc daemon using SimpleXMLRPCServer.
> Following a cookbook recipe, I am trying to do a double fork so that
> when I exit the shell the daemon remains running. But it doesn't.
> Here is how I start the script
>
>> ssh somehost
>> sudo python mydaemon start&
>
> But when I exit the shell, I lose the process.
You need to close the file descriptors to the controlling TTY. This is how I
do it.
f = file('/dev/null', 'r+')
fd = f.fileno()
os.dup2(fd,0)
os.dup2(fd,1)
os.dup2(fd,2)
f.close()
Beware, sys.stdxxx.close() is not enough.
--
дамјан
Speak softly and carry a cellular phone.
More information about the Python-list
mailing list