>> Close-on-fork is apparently either coming or already here, [...] > We don't have it, but it will be in Posix-8. [...] not sure if > anyone has thought of a way to add it to socket() -
It's looking to me as though more and more syscalls are having to grow flags arguments to do things right. Auto-close-on-fork for socket(), accept(), and socketpair(); per-operation non-blocking for at least some half-dozen calls.... I don't see how to avoid it for socket(). For accept(), it could be shoehorned into a SOL_SOCKET sockopt (SO_AUTO_CLOFORK_ON_ACCEPT, say, better name welcomed). > that doesn't look to be trivial, though it might be possible to abuse > one of the params [socket()] has - probably domain - and add flags in > upper bits ... Possible? Probably. Good? No, IMO. > 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, Well, to work for one particularly important use case. It can work just fine for various other use cases without that. > and having it default "on", which would work, would break almost all > existing non-trivial code). What about having it default to a per-proces (or per-thread) settable state? Mouse