Fork You.. Forking and threading..
Jon Ribbens
jon+usenet at unequivocal.co.uk
Wed Jul 5 13:48:36 EDT 2006
In article <1152120097.590691.202400 at b68g2000cwa.googlegroups.com>, 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
More information about the Python-list
mailing list