diff --git a/src/mp/util.cpp b/src/mp/util.cpp index 408bbf8a..107985e5 100644 --- a/src/mp/util.cpp +++ b/src/mp/util.cpp @@ -110,10 +110,12 @@ int SpawnProcess(int& pid, FdToArgsFn&& fd_to_args) if (pid == -1) { throw std::system_error(errno, std::system_category(), "fork"); } + // Parent process closes the descriptor for socket 0, child closes the descriptor for socket 1. if (close(fds[pid ? 0 : 1]) != 0) { throw std::system_error(errno, std::system_category(), "close"); } if (!pid) { + // Child process must close all potentially open descriptors, except socket 0. int maxFd = MaxFd(); for (int fd = 3; fd < maxFd; ++fd) { if (fd != fds[0]) {