attach: use fd_cloexec()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2018-07-11 23:43:38 +02:00
parent bcbef73392
commit 3f62938a8a
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D

View File

@ -930,16 +930,7 @@ static int attach_child_main(struct attach_clone_payload *payload)
* here, ignore errors.
*/
for (fd = STDIN_FILENO; fd <= STDERR_FILENO; fd++) {
int flags;
flags = fcntl(fd, F_GETFL);
if (flags < 0)
continue;
if ((flags & FD_CLOEXEC) == 0)
continue;
ret = fcntl(fd, F_SETFL, flags & ~FD_CLOEXEC);
ret = fd_cloexec(fd, false);
if (ret < 0) {
SYSERROR("Failed to clear FD_CLOEXEC from file descriptor %d", fd);
goto on_error;