Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
listen_for_commands: stop leaking the control socket to forked procs
All the exec'ed processes would get copies of the control socket descriptors, because of the default UNIX semantics of fd inherit across execv(). This was easily seen on my system where an 'lsof' revealed that all my terminals and shells had a copy. To fix this we add the SOCK_CLOEXEC flag whilst opening the listener socket(), avoiding this problem. We also need to set CLOEXEC on the socket returned by accept(): "accept() ... extracts the first connection request on the queue of pending connections ... creates a new connected socket, and returns a new file descriptor" The new descriptor does not inherit CLOEXEC flag from the listener. The "bar" descriptor already handles this by setting O_CLOEXEC in its own open() call on the FIFO.
- Loading branch information