lkml.org 
[lkml]   [1999]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: FD_CLFORK or equivalent?
On Wed, 5 May 1999, Harald Koenig wrote:

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

Yes. This means that a lot os SYS-V stuff that does this is broken.
I noticed this later. The only machine that I found that complied
with the notion of the next fd's value being one greater than the
highest open fd, is my old VAX.

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.


-
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/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.665 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site