Re: [2.4.2/Linux] Getting Python to fork?

2008-02-13 Thread Gilles Ganault
On Mon, 04 Feb 2008 16:40:01 +0100, Rolf van de Krol [EMAIL PROTECTED] wrote: To create a deamon, you indeed need to fork two times. Do I really need this much complication just to exit the script and let a child handle the pop-up? I've changed this line, and the parent still doesn't return, and

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-04 Thread Jon Ribbens
On 2008-02-04, Christian Heimes [EMAIL PROTECTED] wrote: Jon Ribbens wrote: Why? I don't think you do. Neither does BSD daemon.c or glibc daemon.c The problem is well documented at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 OK I understand what is being said here,

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-04 Thread Rolf van de Krol
To create a deamon, you indeed need to fork two times. For more information and a working example see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 . I'm quite sure this works, because I used it several times to create a deamon. Jon Ribbens wrote: On 2008-02-04, Christian

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-04 Thread Jon Ribbens
On 2008-02-04, Gilles Ganault [EMAIL PROTECTED] wrote: I need to launch a Python script, and fork it so that the calling script can resume with the next step will the Python script keeps running. I tried those two, but they don't work, as the calling script is stuck until the Python

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-04 Thread Jon Ribbens
On 2008-02-04, Rolf van de Krol [EMAIL PROTECTED] wrote: To create a deamon, you indeed need to fork two times. For more information and a working example see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 . I'm quite sure this works, because I used it several times to

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-04 Thread Christian Heimes
Jon Ribbens wrote: This should work I believe: 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 Although bear in mind it's pretty UNIX-y.

Re: Getting Python to fork?

2008-02-04 Thread Jon Ribbens
On 2008-02-04, Bernard [EMAIL PROTECTED] wrote: #Fork and commit suicide if os.fork(): sys.exit(0) I'm pretty sure that should be os._exit(0) #What to do in parent process This is now the child process. sys.stdin =

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-04 Thread Christian Heimes
Jon Ribbens wrote: Why? I don't think you do. Neither does BSD daemon.c or glibc daemon.c The problem is well documented at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 The second fork _is_ necessary, Jonathan Bartlett, 2003/10/31 The first fork accomplishes two things -

Re: Getting Python to fork?

2008-02-04 Thread Christian Heimes
Jon Ribbens wrote: I think that's changing Python's idea of stdin etc but not the operating system's idea of them. You won't be closing the original file descriptors, and if you run any subprocesses they will end up with the original stdin/out/err. Unless sys.stdin is more magic than I'm

Re: Getting Python to fork?

2008-02-04 Thread Bernard
On 3 fév, 21:52, Gilles Ganault [EMAIL PROTECTED] wrote: Hello I need to launch a Python script, and fork it so that the calling script can resume with the next step will the Python script keeps running. I tried those two, but they don't work, as the calling script is stuck until

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-04 Thread Jon Ribbens
On 2008-02-04, Christian Heimes [EMAIL PROTECTED] wrote: Although bear in mind it's pretty UNIX-y. IIRC you have to fork a second time after you have changed the working dir and created a new session group. Why? I don't think you do. Neither does BSD daemon.c or glibc daemon.c --

[2.4.2/Linux] Getting Python to fork?

2008-02-03 Thread Gilles Ganault
Hello I need to launch a Python script, and fork it so that the calling script can resume with the next step will the Python script keeps running. I tried those two, but they don't work, as the calling script is stuck until the Python script ends: sys.stdout = open(os.devnull, 'w')

Re: [2.4.2/Linux] Getting Python to fork?

2008-02-03 Thread Gary Herron
Gilles Ganault wrote: Hello I need to launch a Python script, and fork it so that the calling script can resume with the next step will the Python script keeps running. I tried those two, but they don't work, as the calling script is stuck until the Python script ends: sys.stdout =