> > > if (setsid() fails)
> > > always log error
> > > exit(1) unless no_detach.
> >
> > should that be
> > exit(1) if no_detach
> > ? or do I have the logic backward?
>
> We should exit if setsid() fails and we don't want to detach (i.e.
> no_detach). If we don't exit at that point we will end up killing processes in
> the wrong pgrp later. So I think Aaron's right.
Now that I think about it a little more, we should probably always
exit if setsid() fails. It might be useful to change the error message
if no_detach is set ("setsid() failed probably because you aren't
running under a process management tool like daemontools" vs "setsid()
failed, unable to create new session"). Then we just do the fork fork()
if !no_detach. Confused yet?
-aaron