Try to use FD_CLOEXEC instead of mass-closing everywhere.