All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Michal Schmidt <xschmi00@stud.feec.vutbr.cz>
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 09:15:23 -0800	[thread overview]
Message-ID: <4563342B.9050500@zytor.com> (raw)
In-Reply-To: <4562C741.800@stud.feec.vutbr.cz>

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

      reply	other threads:[~2006-11-21 17:15 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
2006-11-21 17:15     ` H. Peter Anvin [this message]

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=4563342B.9050500@zytor.com \
    --to=hpa@zytor.com \
    --cc=Simon.Richter@hogyros.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xschmi00@stud.feec.vutbr.cz \
    /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.