tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: fcntl & cmsg
On Mon, 22 Sep 2014 05:26:47 +0000
David Holland <dholland-tech%netbsd.org@localhost> wrote:
> - fd passing is like calling dup2() except that (once received) the
> new fd appears in another process;
>
> - this means that the close-on-exec flag, which is per file handle,
> is not shared;
>
> - everything else is an attribute of the open file object (or in
> some cases the vnode, e.g. with F_SETLK or flock()) and should be
> shared between the two references.
Thank you, David. That conforms with my tests.
The fd read by the receiving process has the very same properties as
the sender's, except that close-on-exec is cleared. Other flags,
notably O_ASYNC and O_DIRECT, remain in force. So do record locks.
My question arose from unix(4) page because it refers to "per-process
descriptor flags". The Linux unix(7) page I have handy seems to hold a
clue:
"The [F_GETFD and F_SETFD] commands manipulate the flags
associated with a file descriptor. Currently, only one such flag is
defined: FD_CLOEXEC, the close-on-exec flag."
It would seem that while the earth was still cooling someone had the
intention of creating other flags associated with the descriptor that
dup(2) would not propagate. Our unix(4) stands athwart the continents
declaring all such flags behave that way, a fact beyond dispute. Never
mind that the set has only one member!
I don't feel qualified to offer a change the documentation yet. At
Greg's suggestion I did start to read the code, but I'm a long way from
understanding it.
--jkl
Home |
Main Index |
Thread Index |
Old Index