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



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

.



Relevant Pages

  • Re: Ask EU: 42 days detention
    ... what the limit for habeas corpus used to be originally, but IIRC it was ... nearer three days than three months. ... Bear in mind that, as far as I know, no terror suspect has even had to ...
    (uk.media.radio.archers)
  • Re: What Sir Frank thinks
    ... IIRC DH was ... Bear in mind, it wasn't long before that Williams lost another ...
    (rec.autos.sport.f1)
  • Re: Tom Tom One Question
    ... Tom Tom one does NOT say street names. ... Good choice, but still no street names, IIRC. ... Bear in mind that my statements reflect knowledge of 8 months ...
    (rec.outdoors.rv-travel)
  • Re: increasing the RPS of any page
    ... - performance test as you develop, getting ridding of slow or cpu ... - remember that response.write(your html) is probably much more ... also bear in mind the big difference between slow through waiting (low ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Technical issue with this site
    ... you're confused (or ignorant) of what you're posting to in the first ... You have to bear in mind that my first exposure to computers ... That hair would, for Tina, be a six-inch steel hawser. ...
    (rec.arts.sf.composition)