On Wed, Oct 6, 2010 at 12:32, Michael Hanselmann <[email protected]> wrote:
> Am 6. Oktober 2010 11:58 schrieb Iustin Pop <[email protected]>:
>>     _CloseFDNoErr(pidpipe_read)
>>
>>     # First child process
>> -    os.chdir("/")
>> -    os.umask(077)
>> -    os.setsid()
>> +    SetupDaemonEnv()
>>
>>     # And fork for the second time
>>     pid = os.fork()
>> @@ -354,7 +367,8 @@ def _StartDaemonChild(errpipe_read, errpipe_write,
>>       # Exit first child process
>>       os._exit(0) # pylint: disable-msg=W0212
>>
>> -    # Make sure pipe is closed on execv* (and thereby notifies original 
>> process)
>> +    # Make sure pipe is closed on execv* (and thereby notifies
>> +    # original process)
>>     SetCloseOnExecFlag(errpipe_write, True)
>>
>>     # List of file descriptors to be left open
>> @@ -2132,18 +2146,16 @@ def Daemonize(logfile):
>>   """
>>   # pylint: disable-msg=W0212
>>   # yes, we really want os._exit
>> -  UMASK = 077
>> -  WORKDIR = "/"
>>
>>   # this might fail
>>   pid = os.fork()
>>   if (pid == 0):  # The first child.
>> -    os.setsid()
>> +    SetupDaemonEnv()
>> +
>>     # this might fail
>>     pid = os.fork() # Fork a second child.
>>     if (pid == 0):  # The second child.
>> -      os.chdir(WORKDIR)
>> -      os.umask(UMASK)
>> +      pass # nothing special to do in the child
>>     else:
>
> if pid != 0:
>  os._exit(0)

This is intentional, and the 'pass' is replaced in later code with a
different snippet.

iustin

>
>>       # exit() or _exit()?  See below.
>>       os._exit(0) # Exit parent (the first child) of the second child.
>
> Rest LGTM
>
> Michael
>

Reply via email to