[UNIX] Detaching from parent process

Florian Weimer Florian.Weimer at RUS.Uni-Stuttgart.DE
Tue Apr 25 13:15:52 EDT 2000


I'm trying to implement a CVS loginfo script with Python.  The script
has to fork to the background, because the parent process has to
release the repository lock.  But it seems as if Python doesn't detach
completely from the parent process, because CVS exists only after the
lengthy operation has completed.

Currently I use the following code:

    if os.fork() == 0:
        os.setsid()
        if os.fork() == 0:
            os.close(0)
            os.close(1)
            os.close(2)
            os.open("/dev/null", os.O_RDWR)
            os.dup(0)
            os.dup(0)
            # Lengthy operation claiming the repository lock follows.

-- 
Florian Weimer 	                  Florian.Weimer at RUS.Uni-Stuttgart.DE
University of Stuttgart           http://cert.uni-stuttgart.de/
RUS-CERT                          +49-711-685-5973/fax +49-711-685-5898
http://ca.uni-stuttgart.de:11371/pks/lookup?op=get&search=0xC06EC3B5



More information about the Python-list mailing list