lkml.org 
[lkml]   [2006]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: RFC: implement daemon() in the kernel
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?

>
>> _exit(0);
>
> setsid();
>> }
>>

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

\
 
 \ /
  Last update: 2006-11-21 10:33    [W:1.263 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site