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

Re: [Xen-devel] Re: [Xen-changelog] [xen-unstable] xenstored: Do not write to stderr if we are daemonised!


  • To: "Daniel P. Berrange" <berrange@xxxxxxxxxx>, John Levon <levon@xxxxxxxxxxxxxxxxx>
  • From: Keir Fraser <keir@xxxxxxxxxxxxx>
  • Date: Wed, 01 Aug 2007 19:32:59 +0100
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 01 Aug 2007 11:30:52 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: AcfUamKloO/GtEBdEdyIPAAX8io7RQ==
  • Thread-topic: [Xen-devel] Re: [Xen-changelog] [xen-unstable] xenstored: Do not write to stderr if we are daemonised!

Good idea. Can't use _PATH_DEVNULL easily though, since it'll break Solaris
again (no paths.h). Hardcoding /dev/null is not so bad -- the console daemon
does this already.

 -- Keir

On 1/8/07 19:20, "Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:

> Yep, rather than closing FD's and setting the FILE* to NULL, the daeon
> code should re-open /dev/null for stdin/out/err which is the traditional
> approach for most UNIX daemons.
> 
>         if (dofork) {
>                 int devnull;
>                 devnull = open(_PATH_DEVNULL, O_RDWR);
>                 close(STDIN_FILENO);
>                 close(STDOUT_FILENO);
>                 close(STDERR_FILENO);
>                 dup2(devnull, STDIN_FILENO);
>                 dup2(devnull, STDOUT_FILENO);
>                 dup2(devnull, STDERR_FILENO);
>                 close(devnull);
>         }


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.