"fork and exit" needed?

sjdevnull at yahoo.com sjdevnull at yahoo.com
Tue Nov 28 01:46:47 CET 2006


Vincent Delporte wrote:
> Hi
>
> 	I'm a Python newbie, and would like to rewrite this Perl scrip
> to be run with the Asterisk PBX:
>
> http://www.voip-info.org/wiki/view/Asterisk+NetCID
>
> Anyone knows if those lines are necessary, why, and what their
> alternative is in Python?

> open STDOUT, '>/dev/null';

Either redefine stdout to an open file object for /dev/null or run the
script as "script.py >/dev/null"

> fork and exit;
something like:

if os.fork():
   sys.exit(0)

Tells the parent to exit after the fork while the child keeps running.
These are both steps in becoming a daemon (the comp.unix.programmer
FAQ, while skewed toward C, explains why some of these steps are
needed).




More information about the Python-list mailing list