Re: Fw: epoll and fork()

From: Davide Libenzi
Date: Wed Mar 03 2004 - 05:38:48 EST


On Tue, 2 Mar 2004, Chris Friesen wrote:

> Davide Libenzi wrote:
>
> > Sorry but what behaviour do you expect by unregistering an fd pushed by
> > the parent from inside a child? Events work exactly the same. Since the
> > context is shared, events are delivered only once.
>
> For principle of least surprise, I would expect that the refcounts would
> be bumped up so that the child could deregister without affecting the
> parent.
>
> Closing the fd in the child doesn't affect the fd in the parent.
> Removing an fd from an fd_set in the child doesn't affect the fd_set in
> the parent. Unregistering an fd from an epoll set in the child
> shouldn't affect the parent either.

There are two issues here. One is the fact that *explicitly* unregistering
the fd in one task and expecting the other one to act as if it was
registered could be considered a sign of a not clean interaction between
parent and child. The ref-count thing would not work because it is the
kernel that automatically and directly bumps the ref count, w/out calling
any f_op->xxxx() (like for example use/release). So epoll would have to
hook the file get function, detect if the fd is inside an epoll fd, and
take proper action by bumping its count. IMO it is not worth even
considering.



- 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 http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/