On Fri, 11.11.11 14:12, Miloslav Trmač (m...@volny.cz) wrote:

> On Fri, Nov 11, 2011 at 2:05 PM, Lennart Poettering
> <mzerq...@0pointer.de> wrote:
> > Note that only double-forking
> > will properly detach a process from the parent it is started from on
> > Unix, and hence is not an option but mandatory to do
> 
> In the traditional SysV, the process executing /etc/init.d/$service
> will exit immediately afterwards.  Isn't that structurally equivalent
> to double-forking within the service?

No.

In SysV it is expected that when you run "/etc/init.d/foobar start" and
this command completes the service is fully initialized, the PID file
written and the service accessible. That means that you need to double
fork and in the parent process wait until initialization is
complete. That won't work if you leave the second fork to the invoking
shell, since the shell will have it much harder to wait until the
service initialization completed. 

On top of that, you need to invoke setsid() between the two forks, which
you can't really do if you only have one fork().

Please have a look at the check list in daemon(7).

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel

Reply via email to