Topi Miettinen <[EMAIL PROTECTED]> writes:

> At least atd, tcplogd, icmplogd and xfs don't do setsid(). How about adding
> some coding advice in Policy, something like your sentence?

I don't think it's the policy document's job to teach people how to do
Unix system programming.

Lack of an setsid() doesn't necessarily imply that there's a bug.
There are other, more complicated, ways to make sure that you don't
have a controlling terminal, but unless you care about ancient Unixes
I wouldn't worry about them.

Startup code for a daemon would usually look something like (naturally
you would have to add error checking):

if (fork() == 0)
    exit(0);
setsid();
chdir("/");
umask(0);
for (i=0; i<sysconf(_SC_OPEN_MAX); i++)
    close(i);


Guy

Reply via email to