Subject: | Daemon::Generic::gd_daemonize() should fork() after setsid() |
Date: | Tue, 07 Dec 2010 10:22:14 -0500 |
To: | bug-daemon-generic [...] rt.cpan.org |
From: | "Nicholas R. Markham" <markhn [...] rpi.edu> |
I'm not entirely sure if this is a bug or if it's intentional. However,
I claim that in Daemon::Generic 0.71, the gd_daemonize() function could
benefit from a slightly different sequence of system calls.
Specifically, I would suggest fork...setsid...fork instead of
fork...fork...setsid.
I did a little research and couldn't find a clear answer on whether it's necessary to fork after calling setsid. Clearly it isn't as important as the first fork, but it seems like it's a good idea on at least some platforms. (e.g. http://h21007.www2.hp.com/portal/download/files/unprot/stk/tru64_stk/impacts/i260.html)
Moreover, I can't find any reference to forking twice before calling
setsid, so that makes me think the author intended the "usual"
fork...setsid...fork paradigm and transposed the last two inadvertently.
Love the module!