All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: John Levon <levon@movementarian.org>
Cc: xen-devel@lists.xensource.com
Subject: Re: Re: [Xen-changelog] [xen-unstable] xenstored: Do not write to stderr if we are daemonised!
Date: Wed, 1 Aug 2007 19:20:27 +0100	[thread overview]
Message-ID: <20070801182027.GN31282@redhat.com> (raw)
In-Reply-To: <20070801180323.GA16021@totally.trollied.org.uk>

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  -=| 

  parent reply	other threads:[~2007-08-01 18:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200708011653.l71GrIcp032245@xenbits.xensource.com>
2007-08-01 18:03 ` [Xen-changelog] [xen-unstable] xenstored: Do not write to stderr if we are daemonised! John Levon
2007-08-01 18:12   ` Keir Fraser
2007-08-01 18:22     ` John Levon
2007-08-01 22:36     ` Alan Cox
2007-08-01 18:20   ` Daniel P. Berrange [this message]
2007-08-01 18:32     ` Keir Fraser
2007-08-01 18:35       ` John Levon

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=20070801182027.GN31282@redhat.com \
    --to=berrange@redhat.com \
    --cc=levon@movementarian.org \
    --cc=xen-devel@lists.xensource.com \
    /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.