Re: F_DUPFD_CLOEXEC implementation

From: Davide Libenzi
Date: Tue Oct 02 2007 - 15:52:55 EST


On Tue, 2 Oct 2007, Denys Vlasenko wrote:

> I have following proposals:
>
> * make recv(..., MSG_DONTWAIT) work on any fd
>
> Sounds neat, but not trivial to implement in current kernel.

This is mildly ugly, if you ask me. Those are socket functions, and the
flags parameter contain some pretty specific network meanings.



> * new fcntl command F_DUPFL: fcntl(fd, F_DUPFL, n):
> Analogous to F_DUPFD, but gives you *unshared* copy of the fd.
> Further seeks, fcntl(fd, F_SETFL, O_NONBLOCK), etc won't affect
> any other process.

You'll need an ad-hoc copy function though, since your memcpy-based one is
gonna explode even before memcpy returns ;) You'll have problems with
ref-counting too. And that layer is not designed to cleanly support that
operation.
Unfortunately the "clean" solution would involve changing a whole bunch of
code, and I don't feel exactly sure it'd be worth it.



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