Re: RFC: implement daemon() in the kernel

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

 



Michal Schmidt wrote:
H. Peter Anvin wrote:
Simon Richter wrote:
int daemon(int nochdir, int noclose)
{
    if(!nochdir)
        chdir("/");

    if(!noclose)
    {
        int fd = open("/dev/null", O_RDWR);
        dup2(fd, 0);
        dup2(fd, 1);
        dup2(fd, 2);
        close(fd);
    }

    if(fork() > 0)

... that should be if (fork() == 0) ...

Are you sure? fork()==0 means we're the child, but it's the parent who should exit, isn't it?


Oh, right, of course. Thinko; the lack of error handling confused me. I did that right in the assembly code.

	-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux