slave: turn on FD_CLOEXEC after slave has been spawned

This ensures that our ptmx FD isn't carried over to other terminals
spawned later.
This commit is contained in:
Daniel Eklöf 2019-11-03 01:14:02 +01:00
parent 8d9ad96b52
commit 8cf981ca12
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -127,6 +127,15 @@ slave_spawn(int ptmx, int argc, char *const *argv,
return -1;
} else
LOG_DBG("%s: successfully started", conf_shell);
int fd_flags;
if ((fd_flags = fcntl(ptmx, F_GETFD)) < 0 ||
fcntl(ptmx, F_SETFD, fd_flags | FD_CLOEXEC) < 0)
{
LOG_ERRNO("failed to set FD_CLOEXEC on ptmx");
return -1;
}
break;
}
}