Fork You.. Forking and threading..

rh0dium steven.klass at gmail.com
Thu Jul 6 17:06:03 EDT 2006


Hi Nick!

This is much better than the kludge job I did -  Thanks for the help!!


Nick Craig-Wood wrote:
> rh0dium <steven.klass at gmail.com> wrote:
> >  I have a problem with putting a job in the background. Here is my
> >  (ugly) script which I am having problems getting to background.  There
> >  are threads about doing
> >
> >       python script.py &
> >
> >  and others
> >
> >       nohup python script.py &
> >
> >  and yet others
> >
> >       ( python script.py > /dev/null & ) &
> >
> >  Regardless timing these all produce (roughly the same time) and none of
> >  them are backgrounded..
>
> I suspect you want the old fork/setsid/fork trick...
>
>   http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012
>
> That releases the controlling terminal from your job and it exits
> from the process group.
>
> You could probably close / redirect stdin/out/err too.  Search for
> daemonize.py and you'll find a module which does all this.
>
> --
> Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick




More information about the Python-list mailing list