All of lore.kernel.org
 help / color / mirror / Atom feed
From: malahal@us.ibm.com <malahal@us.ibm.com>
To: lvm-devel@redhat.com
Subject: [PATCH] Remove the double open with same mode
Date: Mon, 15 Mar 2010 10:41:33 -0700	[thread overview]
Message-ID: <20100315174133.GA3188@us.ibm.com> (raw)
In-Reply-To: <20100313041826.GB7267@agk-dp.fab.redhat.com>

Alasdair G Kergon [agk at redhat.com] wrote:
> On Fri, Mar 12, 2010 at 04:17:56PM -0800, Malahal Naineni wrote:
> >  	if ((open("/dev/null", O_RDONLY) < 0) ||
> > -	    (open("/dev/null", O_WRONLY) < 0) ||
> >  	    (open("/dev/null", O_WRONLY) < 0))
> >  		exit(EXIT_DESC_OPEN_FAILURE);
> 
> stdin, stdout, stderr

Then how about this:

diff -r 8db1b9ee17a8 daemons/dmeventd/dmeventd.c
--- a/daemons/dmeventd/dmeventd.c	Fri Mar 12 16:15:25 2010 -0800
+++ b/daemons/dmeventd/dmeventd.c	Mon Mar 15 10:38:49 2010 -0700
@@ -1650,9 +1650,10 @@ static void _daemonize(void)
 	for (--fd; fd >= 0; fd--)
 		close(fd);
 
-	if ((open("/dev/null", O_RDONLY) < 0) ||
-	    (open("/dev/null", O_WRONLY) < 0) ||
-	    (open("/dev/null", O_WRONLY) < 0))
+	/* open stdin, stdout, stderr */
+	if ((open("/dev/null", O_RDONLY) != 0) ||
+	    (open("/dev/null", O_WRONLY) != 1) ||
+	    (open("/dev/null", O_WRONLY) != 2))
 		exit(EXIT_DESC_OPEN_FAILURE);



  parent reply	other threads:[~2010-03-15 17:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-13  0:17 [PATCH] Remove the double open with same mode Malahal Naineni
2010-03-13  4:18 ` Alasdair G Kergon
2010-03-15  8:59   ` Zdenek Kabelac
2010-03-15 15:37     ` Bryn M. Reeves
2010-03-15 16:58     ` Tim Post
2010-03-15 17:41   ` malahal [this message]
2010-03-15 18:16     ` Alasdair G Kergon

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=20100315174133.GA3188@us.ibm.com \
    --to=malahal@us.ibm.com \
    --cc=lvm-devel@redhat.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.