Daemonize?

Oren Tirosh oren-py-l at hishome.net
Sat Sep 7 22:10:22 CEST 2002


On Sat, Sep 07, 2002 at 10:49:57AM -0700, Neil Schemenauer wrote:
> Oren Tirosh wrote:
> >     devnull = os.open('/dev/null', 0)
> >     os.dup2(devnull, 0)
> >     os.dup2(devnull, 1)
> >     os.dup2(devnull, 2)
> > 
> > This is safer because it prevents these file descriptors from being reused.
> 
> Better:
> 
>     os.close(sys.__stdin__.fileno())
>     os.close(sys.__stdout__.fileno())
>     os.close(sys.__stderr__.fileno())
>     os.open('/dev/null', 0)
>     os.dup(0)
>     os.dup(0)

Any particular reason why you think this is better?

	Oren





More information about the Python-list mailing list