Re: Fork You.. Forking and threading..
Hi Nick! This is much better than the kludge job I did - Thanks for the help!! Nick Craig-Wood wrote: rh0dium [EMAIL PROTECTED] 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 [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Fork You.. Forking and threading..
On 2006-07-05, rh0dium [EMAIL PROTECTED] wrote: Hi all, 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. Yes they are -- unless you're using a different definition of the word backgrounded than the rest of the Unix world. What do you mean by backgrounded? What are you trying to accomplish? -- Grant Edwards grante Yow! Yow!! That's a GOOD at IDEA!! Eating a whole FIELD visi.comof COUGH MEDICINE should make you feel MUCH BETTER!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Fork You.. Forking and threading..
In article [EMAIL PROTECTED], rh0dium wrote: if os.fork() == 0: os.setsid sys.stdout = open(/dev/null, 'w') sys.stdin = open(/dev/null, 'r') I don't know if it's the cause of your problem, but you're not doing the backgrounding right, it should be: if os.fork(): os._exit(0) os.setsid() os.chdir(/) fd = os.open(/dev/null, os.O_RDWR) os.dup2(fd, 0) os.dup2(fd, 1) os.dup2(fd, 2) if fd 2: os.close(fd) # do stuff -- http://mail.python.org/mailman/listinfo/python-list
Re: Fork You.. Forking and threading..
rh0dium [EMAIL PROTECTED] 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 [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list