Fork You.. Forking and threading..

Nick Craig-Wood nick at craig-wood.com
Wed Jul 5 14:30:04 EDT 2006


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