From: Michal Schmidt <xschmi00@stud.feec.vutbr.cz>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Simon Richter <Simon.Richter@hogyros.de>, linux-kernel@vger.kernel.org
Subject: Re: RFC: implement daemon() in the kernel
Date: Tue, 21 Nov 2006 10:30:41 +0100 [thread overview]
Message-ID: <4562C741.800@stud.feec.vutbr.cz> (raw)
In-Reply-To: <45624A91.3010604@zytor.com>
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
next prev parent reply other threads:[~2006-11-21 9:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-20 13:20 RFC: implement daemon() in the kernel Simon Richter
2006-11-20 15:38 ` Mark Rustad
2006-11-20 17:42 ` Simon Richter
2006-11-20 20:48 ` Mark Rustad
2006-11-20 20:38 ` Jan Engelhardt
2006-11-21 0:38 ` H. Peter Anvin
2006-11-21 9:30 ` Michal Schmidt [this message]
2006-11-21 17:15 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4562C741.800@stud.feec.vutbr.cz \
--to=xschmi00@stud.feec.vutbr.cz \
--cc=Simon.Richter@hogyros.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.