All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Remove the double open with same mode
@ 2010-03-13  0:17 Malahal Naineni
  2010-03-13  4:18 ` Alasdair G Kergon
  0 siblings, 1 reply; 7+ messages in thread
From: Malahal Naineni @ 2010-03-13  0:17 UTC (permalink / raw)
  To: lvm-devel

Signed-off-by: Malahal Naineni (malahal at us.ibm.com)

diff -r 8db1b9ee17a8 -r ee77738483f1 daemons/dmeventd/dmeventd.c
--- a/daemons/dmeventd/dmeventd.c	Fri Mar 12 16:15:25 2010 -0800
+++ b/daemons/dmeventd/dmeventd.c	Fri Mar 12 16:16:15 2010 -0800
@@ -1651,7 +1651,6 @@ static void _daemonize(void)
 		close(fd);
 
 	if ((open("/dev/null", O_RDONLY) < 0) ||
-	    (open("/dev/null", O_WRONLY) < 0) ||
 	    (open("/dev/null", O_WRONLY) < 0))
 		exit(EXIT_DESC_OPEN_FAILURE);
 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Remove the double open with same mode
  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 17:41   ` malahal
  0 siblings, 2 replies; 7+ messages in thread
From: Alasdair G Kergon @ 2010-03-13  4:18 UTC (permalink / raw)
  To: lvm-devel

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

Alasdair



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Remove the double open with same mode
  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
  1 sibling, 2 replies; 7+ messages in thread
From: Zdenek Kabelac @ 2010-03-15  8:59 UTC (permalink / raw)
  To: lvm-devel

On 13.3.2010 05:18, Alasdair G Kergon 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
> 
> Alasdair
> 

IMHO it's probably worth to add comment to code, so there will not be similar
'optimizations' proposed in the future.

Zdenek.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Remove the double open with same mode
  2010-03-15  8:59   ` Zdenek Kabelac
@ 2010-03-15 15:37     ` Bryn M. Reeves
  2010-03-15 16:58     ` Tim Post
  1 sibling, 0 replies; 7+ messages in thread
From: Bryn M. Reeves @ 2010-03-15 15:37 UTC (permalink / raw)
  To: lvm-devel

On Mon, 2010-03-15 at 09:59 +0100, Zdenek Kabelac wrote:
> On 13.3.2010 05:18, Alasdair G Kergon 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
> > 
> > Alasdair
> > 
> 
> IMHO it's probably worth to add comment to code, so there will not be similar
> 'optimizations' proposed in the future.

Or dup(2) stdout onto stderr - iirc this is how the code in init/main.c
in the kernel is organised and it does make things a little bit more
obvious / readable.

Regards,
Bryn.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Remove the double open with same mode
  2010-03-15  8:59   ` Zdenek Kabelac
  2010-03-15 15:37     ` Bryn M. Reeves
@ 2010-03-15 16:58     ` Tim Post
  1 sibling, 0 replies; 7+ messages in thread
From: Tim Post @ 2010-03-15 16:58 UTC (permalink / raw)
  To: lvm-devel

On Mon, 2010-03-15 at 09:59 +0100, Zdenek Kabelac wrote:
> On 13.3.2010 05:18, Alasdair G Kergon 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
> > 
> > Alasdair
> > 
> 
> IMHO it's probably worth to add comment to code, so there will not be similar
> 'optimizations' proposed in the future.
> 
> Zdenek.

I don't see how its confusing?

Regards,
--Tim




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Remove the double open with same mode
  2010-03-13  4:18 ` Alasdair G Kergon
  2010-03-15  8:59   ` Zdenek Kabelac
@ 2010-03-15 17:41   ` malahal
  2010-03-15 18:16     ` Alasdair G Kergon
  1 sibling, 1 reply; 7+ messages in thread
From: malahal @ 2010-03-15 17:41 UTC (permalink / raw)
  To: lvm-devel

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Remove the double open with same mode
  2010-03-15 17:41   ` malahal
@ 2010-03-15 18:16     ` Alasdair G Kergon
  0 siblings, 0 replies; 7+ messages in thread
From: Alasdair G Kergon @ 2010-03-15 18:16 UTC (permalink / raw)
  To: lvm-devel

On Mon, Mar 15, 2010 at 10:41:33AM -0700, malahal at us.ibm.com wrote:
> 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);
 
Nack.  Complete waste of time.

Alasdair.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-03-15 18:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2010-03-15 18:16     ` Alasdair G Kergon

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.