Messages in this thread | | | Date | Wed, 5 May 1999 19:06:45 +0200 | From | Harald Koenig <> | Subject | Re: FD_CLFORK or equivalent? |
| |
On May 05, Richard B. Johnson wrote:
> On Wed, 5 May 1999, Bernd Eckenfels wrote: > > > In article <Pine.QNX.3.96.990504112943.30630A-100000@sam.cogent.ca> you wrote: > > > If not, before I hack one in as a private kernel patch, is > > > there any reason to add such a mechanism, perhaps a FD_CLOFORK > > > flag, and does anybody have suggestions on where to start? > > > > A reason would be, that this is a good way of making daemons. Since closing > > all fds from 0-255 is not enough on systems where high-numberes fds can be > > open. > > > But... The 'standard' way is: > > fd = open("/", O_RDONLY); > while (fd >= 0) (void)close(fd--); >
this `standard way' is broken!
main() { close(0); printf("%d\n",open ("/",0)); }
will output 0 (zero) using glibc-2.0.7. so your `standard way' won't close fds 1 and 2 after a close(0)...
Harald -- All SCSI disks will from now on ___ _____ be required to send an email notice 0--,| /OOOOOOO\ 24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\ \ \/OOOOOOOOOOOOOOO\ \ OOOOOOOOOOOOOOOOO|// Harald Koenig, \/\/\/\/\/\/\/\/\/ Inst.f.Theoret.Astrophysik // / \\ \ koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |