On Mon, 15 Apr 2002, Chris Crowther wrote:

> On Sun, 14 Apr 2002, Kev wrote:
> 
> > > daemon(1,0);
> 
> > Doesn't seem to be documented for Solaris.  I rather suspect this isn't
> > a standardized function.  (This isn't the first time I've heard of a
> 
>       It's a BSD function iirc, Linux supports it too, but it's hardly
> portable.
> 
>        #include <unistd.h>
> 
>        int daemon (int nochdir, int noclose);
> 

I've bumped into the same problems a few times.
Here is a replacement for daemon(1,0);
(Somewhat simplified w/o error checking)


  if(fork()) {
    exit(0);
  }
  close(0);
  close(1);
  close(2);
  open("/dev/null",0);
  open("/dev/null",0);
  open("/dev/null",0);
  setsid();



Reply via email to