This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-devel] Re: [Xen-changelog] [xen-unstable] xenstored: Do not wri

To: "Daniel P. Berrange" <berrange@xxxxxxxxxx>, John Levon <levon@xxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [Xen-changelog] [xen-unstable] xenstored: Do not write to stderr if we are daemonised!
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
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20070801182027.GN31282@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcfUamKloO/GtEBdEdyIPAAX8io7RQ==
Thread-topic: [Xen-devel] Re: [Xen-changelog] [xen-unstable] xenstored: Do not write to stderr if we are daemonised!
User-agent: Microsoft-Entourage/
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