On Sun, 10 Jun 2007, Paul Mackerras wrote:
> > for (i = 0; i < NR_OPEN; i++)
> > if (!fd_is_special_to_us(i))
> > close(i);
> >
> > Note that this is conceptually buggy, but occurs in several major C
> > programming books, most of the major shells, and a lot of other
> > software to boot.
>
> Buggy in what way? In the use of the NR_OPEN constant?
That is buggy because the code assumes it is the only owner of the fd
space. Thing that is not true if runtimes have opened their own file
descriptors to handle their own links to the kernel.
The syslog case is kinda bogus. For certain things, you can afford a retry
policy (assuming somone else did not open another fd over the fd that you
cached - then it's gonna be fun). It is crappy, but it *may* work. Sure
is, does not fit any definition of "reliable" I'm aware of.
Think about a runtime that had an epoll fd open and a few fds dropped into
it to, say, deliver some sort of events to the application. After the
Close Loop of Death, the whole thing is gone.
As is, runtimes cannot reliably use (cached) fds for their own internal
communication with the kernel. That, I think we can agree it is a fact.
We can then say that we do not care if runtimes cannot reliably use fds,
and move on. But it's hard to say that the problem does not exist.
- Davide
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]