You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When forking and execing, file descriptors get leaked to the child process, which is not always ideal. One can always call fcntl and set O_CLOEXEC after establishing a connection, but this can lead to race conditions if a different thread is trying to fork.
Apart from OS compatibility, are there any cases where one might want this sort of behaviour, meaning the sockets couldn't be created with SOCK_CLOEXEC? If so, how could we implement some sort of flag or another Connect* in order to accommodate for that?
I've been bitten by this at work and I went with calling fcntl, but I'd like to have a more atomic fix, and I'm willing to contribute a patch to this, I'd just like to have some input on what sort of API/behaviour is best. :)
The text was updated successfully, but these errors were encountered:
When
fork
ing andexec
ing, file descriptors get leaked to the child process, which is not always ideal. One can always callfcntl
and setO_CLOEXEC
after establishing a connection, but this can lead to race conditions if a different thread is trying tofork
.Apart from OS compatibility, are there any cases where one might want this sort of behaviour, meaning the sockets couldn't be created with
SOCK_CLOEXEC
? If so, how could we implement some sort of flag or anotherConnect*
in order to accommodate for that?I've been bitten by this at work and I went with calling
fcntl
, but I'd like to have a more atomic fix, and I'm willing to contribute a patch to this, I'd just like to have some input on what sort of API/behaviour is best. :)The text was updated successfully, but these errors were encountered: