Hello! On Sun, Aug 21, 2005 at 09:54:06AM +0200, Alexander Farber wrote: > if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { > (void)dup2(fd, 0); > (void)dup2(fd, 1); > (void)dup2(fd, 2); > if (fd > 2) > (void)close (fd); > }
>right? What is this last check (fd > 2) needed for? Isn't fd always > 2, >because the first 3 are already taken by the STDxxx streams at the >program start? What if any of the descriptors <= 2 are closed before invocation of daemon? Then fd will be <= 2, and if you close it, the desired state (/dev/null open on 0, 1, and 2) will not be achieved. I.e. safety. >Thanks >Alex Kind regards, Hannah.