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, a

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 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 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 H

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: [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 -- http:

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'

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 Py

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

[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')