Creating a daemon process in Python

Jean-Paul Calderone exarkun at divmod.com
Fri Feb 23 10:01:23 EST 2007


On Fri, 23 Feb 2007 08:30:07 -0600, Nick Craig-Wood <nick at craig-wood.com> wrote:
>Eirikur Hallgrimsson <eh at mad.scientist.com> wrote:
>
> [snip]
>
>>          if (not os.fork()):
>>              # hang around till adopted by init
>>              ppid = os.getppid()
>>              while (ppid != 1):
>>                  time.sleep(0.5)
>>                  ppid = os.getppid()
>
>Why do you need hang around until adopted by init?  I've never see
>that in a daemonize recipe before?
>

I think it simplifies some signal handling logic.  I'd never seen it before
in a deamonizer either, but it caught my eye in this one.  I haven't had time
to investigate further though.  I hope Eirikur will explain. :)

Jean-Paul



More information about the Python-list mailing list