Re: [2.4.2/Linux] Getting Python to fork?
- From: Christian Heimes <lists@xxxxxxxxxx>
- Date: Mon, 04 Feb 2008 15:40:49 +0100
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.
IIRC you have to fork a second time after you have changed the working
dir and created a new session group.
Christian
.
- Follow-Ups:
- Re: [2.4.2/Linux] Getting Python to fork?
- From: Jon Ribbens
- Re: [2.4.2/Linux] Getting Python to fork?
- References:
- [2.4.2/Linux] Getting Python to fork?
- From: Gilles Ganault
- Re: [2.4.2/Linux] Getting Python to fork?
- From: Jon Ribbens
- [2.4.2/Linux] Getting Python to fork?
- Prev by Date: Re: Catching a non-Exception object (KeyboardInterrupt)
- Next by Date: Re: type, object hierarchy?
- Previous by thread: Re: [2.4.2/Linux] Getting Python to fork?
- Next by thread: Re: [2.4.2/Linux] Getting Python to fork?
- Index(es):
Relevant Pages
|