From: <no...@so...> - 2009-12-29 13:15:33
|
Update of /cvsroot/ijbswa/current In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15190 Modified Files: jcc.c Log Message: Revert a last-minute 'optimization' in rev 1.99 that could cause fd 1 and 2 being bound to logfp. Yay for procstat(1). Index: jcc.c =================================================================== RCS file: /cvsroot/ijbswa/current/jcc.c,v retrieving revision 1.308 retrieving revision 1.309 diff -u -d -r1.308 -r1.309 --- jcc.c 26 Dec 2009 11:34:01 -0000 1.308 +++ jcc.c 29 Dec 2009 13:15:24 -0000 1.309 @@ -3162,27 +3162,31 @@ * from sending stuff to the clients or servers. */ fd = open("/dev/null", O_RDONLY); - if (fd > 0) + if (fd == -1) + { + log_error(LOG_LEVEL_FATAL, "Failed to open /dev/null: %E"); + } + else if (fd != 0) { if (dup2(fd, 0) == -1) { log_error(LOG_LEVEL_FATAL, "Failed to reserve fd 0: %E"); } close(fd); - fd = open("/dev/null", O_WRONLY); - if ((fd >= 0) && (fd != 1)) - { - if (dup2(fd, 1) == -1) - { - log_error(LOG_LEVEL_FATAL, "Failed to reserve fd 1: %E"); - } - close(fd); - } } + fd = open("/dev/null", O_WRONLY); if (fd == -1) { log_error(LOG_LEVEL_FATAL, "Failed to open /dev/null: %E"); } + else if (fd != 1) + { + if (dup2(fd, 1) == -1) + { + log_error(LOG_LEVEL_FATAL, "Failed to reserve fd 1: %E"); + } + close(fd); + } chdir("/"); |