GemTalk / RemoteServiceReplication

MIT License
0 stars 4 forks source link

RSR sockets should set FD_CLOEXEC #165

Open martinmcclure opened 2 weeks ago

martinmcclure commented 2 weeks ago

RSR sockets should set FD_CLOEXEC on platforms where this is possible.

Otherwise, an open socket will be inherited by any local child processes. A subsequent local close of the RSR connection will not be realized by the remote end, since the socket remains open locally until the child process closes it (or exits).

martinmcclure commented 1 week ago

Pharo does not directly support close-on-exec behavior. There is a Pharo issue for this: https://github.com/pharo-project/pharo/issues/12576

Workaround for Linux: On the Pharo Discord, Pablo reports that you can get a file descriptor from a socket handle like this: (aSocket socketHandle pointerAt: 9) signedLongAt: 1 Given the fd, one should be able to call fcntl. I don't know whether this would work on MacOS.

For Windows, Feenk has found that calling SetHandleInformation can be used to set close-on-exec on a socket. See their issue https://github.com/feenkcom/gtoolkit/issues/4163

Rinzwind commented 5 days ago

Regarding the question in the previous comment of whether that would work on macOS: see the snippet I gave in Zinc issue #101 for setting FD_CLOEXEC on the Zinc server’s socket which, as indicated in the comment in the snippet, I tested on macOS.