WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: John Levon <levon@xxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [Xen-changelog] [xen-unstable] xenstored: Do not write to stderr if we are daemonised!
From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
Date: Wed, 1 Aug 2007 19:20:27 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 01 Aug 2007 11:18:07 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20070801180323.GA16021@xxxxxxxxxxxxxxxxxxxxxxx>
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>
References: <200708011653.l71GrIcp032245@xxxxxxxxxxxxxxxxxxxxx> <20070801180323.GA16021@xxxxxxxxxxxxxxxxxxxxxxx>
Reply-to: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.1i
On Wed, Aug 01, 2007 at 07:03:23PM +0100, John Levon wrote:
> On Wed, Aug 01, 2007 at 09:53:17AM -0700, Xen patchbot-unstable wrote:
> 
> > +
> > +           /* Get ourselves a nice xenstored crash if these are used. */
> > +           stdin = NULL;
> > +           stdout = NULL;
> > +           stderr = NULL;
> 
> You cannot assign to std* on Solaris, this becomes:
> 
>  (&__iob[0]) = 0;
>  (&__iob[1]) = 0;
>  (&__iob[2]) = 0;
> 
> which obviously won't compile.

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);
        }

(With error checking on open/close/dup2 of ccourse)

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

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