Daemonize?

Richard Jones rjones at ekit-inc.com
Wed Sep 4 20:13:48 EDT 2002


On Wed, 4 Sep 2002 11:36 pm, sismex01 at hebmex.com wrote:
> Sorry to ask here, but I don't have any "unixy" python
> documentation at hand.
>
> Normally, I put an app into "daemon" mode, by first
> forking, then reopening stdin/out/err to /dev/null,
> and then forking again. Works good enough for my
> purposes.

Note you can also just assign an object with a write() method that does 
nothing to sys.std(out|err) and a similar object to sys.stdin. Why the second 
fork, btw?


> But, am I right? Is this the correct way to do this?
> Also, I can't find any "reopen" in python to apply
> to sys.stdin/out/err.

All that stuff is handled for you. Simply assigning to the std* attributes is 
enough. Note that in python 2.1+ the "old" sys.std(in|out|err) handles are 
still available as sys.__std(in|out|err)__ if you really need them. 


      Richard





More information about the Python-list mailing list