tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Per-descriptor state
In article <21465.1682869851%jacaranda.noi.kre.to@localhost>,
Robert Elz <kre%munnari.OZ.AU@localhost> wrote:
> Date: Sun, 30 Apr 2023 05:25:41 +0000
> From: David Holland <dholland-tech%netbsd.org@localhost>
> Message-ID: <ZE371Uhm+zXvnBUl%netbsd.org@localhost>
>
> | Close-on-fork is apparently either coming or already here, not sure
> | which, but it's also per-descriptor.
>
>We don't have it, but it will be in Posix-8. Largely inspired by the
>needs of threaded programs (without lots of critical sections, one cannot
>otherwise open anything if another thread might fork, there's no
>way to avoid race conditions, hence O_CLOFORK on open ... not sure if
>anyone has thought of a way to add it to socket() - that doesn't look
>to be trivial, though it might be possible to abuse one of the params
>it has - probably domain - and add flags in upper bits ... while having
>it able to be set/reset via fcntl is useful, to work, it needs to be
>able to be set atomically with the operation that creates the fd, and
>having it default "on", which would work, would break almost all existing
>non-trivial code).
We already abuse "type":
The following flags can be or'ed to the type to condition the returned
file descriptor: The following flags are valid:
SOCK_CLOEXEC Set the close on exec property.
SOCK_NONBLOCK Sets non-blocking I/O.
SOCK_NOSIGPIPE Return EPIPE instead of raising SIGPIPE.
christos
Home |
Main Index |
Thread Index |
Old Index