Remove the double open with same mode
PATCH 1/1 Remove the double open with same mode
daemons/dmeventd/dmeventd.c +0 -1
@@ -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 );
PATCH 1/1 Remove the double open with same mode
daemons/dmeventd/dmeventd.c static void _daemonize(void) · line 1655
Quoted 4 lines · Malahal Naineni
daemons/dmeventd/dmeventd.c +0
-1if ((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
PATCH 1/1 Remove the double open with same mode
Quoted 10 lines · Alasdair G Kergon
daemons/dmeventd/dmeventd.c static void _daemonize(void) · line 1655
Quoted 4 lines · Malahal Naineni
daemons/dmeventd/dmeventd.c +0
-1if ((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.
PATCH 1/1 Remove the double open with same mode
Quoted 9 lines · Zdenek Kabelac
Quoted 8 lines · Alasdair G Kergon
daemons/dmeventd/dmeventd.c static void _daemonize(void) · line 1655
Quoted 4 lines · Malahal Naineni
daemons/dmeventd/dmeventd.c +0
-1if ((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
Quoted 5 lines
Quoted 2 lines
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.
PATCH 1/1 Remove the double open with same mode
In reply to Zdenek KabelacQuoted 9 lines · Zdenek Kabelac
Quoted 8 lines · Alasdair G Kergon
daemons/dmeventd/dmeventd.c static void _daemonize(void) · line 1655
Quoted 4 lines · Malahal Naineni
daemons/dmeventd/dmeventd.c +0
-1if ((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
Quoted 7 lines
Quoted 2 lines
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
PATCH 1/1 Remove the double open with same mode
In reply to Alasdair G KergonQuoted 7 lines · Alasdair G Kergon [agk at redhat.com]
Review
Quoted 4 lines · Malahal Naineni
(quoted diff) +0
-1if ((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:
daemons/dmeventd/dmeventd.c +4 -3
@@ -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 );
PATCH 1/1 Remove the double open with same mode
Quoted 6 lines · malahal at us.ibm.com
Then how about this:
diff -r8db1b9ee17a8daemons/dmeventd/dmeventd.cdaemons/dmeventd/dmeventd.c +0
-0@@ -1650,9 +1650,10 @@ static void _daemonize(void)for (--fd; fd >=0 ; fd--)
daemons/dmeventd/dmeventd.c static void _daemonize(void) · line 1657
Quoted 10 lines
daemons/dmeventd/dmeventd.c +4
-3close (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.