lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 21 Nov 2006 10:30:41 +0100
From:	Michal Schmidt <xschmi00@...d.feec.vutbr.cz>
To:	"H. Peter Anvin" <hpa@...or.com>
CC:	Simon Richter <Simon.Richter@...yros.de>,
	linux-kernel@...r.kernel.org
Subject: Re: 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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ