[squeak-dev] [Vm-dev] [OSProcess] forking and file descriptors
henrik.s.johansen at veloxit.no
Fri Jan 9 09:24:42 UTC 2015
> On 09 Jan 2015, at 9:32 , Max Leske <maxleske at gmail.com> wrote:
> That would mean that I must not close any sockets in the child. One option, it seems to me, is to suspend all processes that use sockets. Terminating them might pose another problem, if socket destruction is part of an unwind block in one of the processes (e.g. TCP connections in Seaside) then sockets will be destroyed during termination.
> Another option: set all the socket handles to nil, then terminate the processes (yes ugly, but it might just work…).
Just beware you might run into the issue that resuming a processes waiting for a semaphore will proceed as if the semaphore were signalled,
Can't tell offhand if that would actually be a problem in this case, or if the affected processes would promptly resume waiting after socket read/writes may initiate with no data.
Another (probably non-portable, which would be painful if not consistent across platforms) option:
Forget about image-side handling, and alter the SocketPlugin to set FD_CLOEXEC if available when opening sockets. (It's in http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html , but that's rather new)
On newer Linuxen, you also have SOCK_CLOEXEC for socket(), which opens/sets in an atomic operation, but the race condition avoided by that is hardly relevant in our case.
More information about the Vm-dev