tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Library support for two-phase daemonization

Alan Barrett wrote:
> Please could you show how to implement daemon() in terms of daemon2_*.

  int daemon(int nochdir, int noclose) {
      int r = daemon_fork();
      if (r == -1)
          return -1;
      return daemon2_detach(nochdir, noclose);

> Could the args be passed to daemon2_fork() instead of to
> daemon2_detach(), to make it easier to convert code from using daemon()
> to daemon2_*()?

I think it is clearer to pass them to the function where they are
actually used.

> If we are redesigning this interface, then perhaps we should go 
> further, and provide a richer list of things to do in between 
> the fork and the detach.  Some possible things one might want to 
> do are:  setuid, chroot, chdir(somewhere other than "/"), 
> anything that posix_spawn() can do.

I'm not trying to do a redesign so much as a minimal extension of
the existing design to solve a specific problem.

If we were to actually do a redesign, it would be nice if we could
avoid having function arguments whose name starts with "no".
Andreas Gustafsson,

Home | Main Index | Thread Index | Old Index