Re: [patch 7/8] fdmap v2 - implement sys_socket2

From: Davide Libenzi
Date: Sun Jun 10 2007 - 11:56:19 EST

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 typical daemonize code done by quite a few apps, and even
described in many unix network programming books. Now say that before that
you loaded a library that had an internal fd allocated to get some sort of
services from the kernel (say an epoll fd). What happens when the library
uses the cached apoll fd after that loop?

- Davide

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at