job-control: set CLOEXEC on pty processes. #5986

Before this change, new processes started with libuv prevented SIGHUP
from reaching pty processes (by keeping the ptmx file descriptor open).
This commit is contained in:
Matthew Malcomson
2017-01-21 14:11:30 +00:00
committed by Justin M. Keyes
parent ad1884be0d
commit f6946c68ae
7 changed files with 77 additions and 35 deletions

View File

@@ -2692,14 +2692,7 @@ static FILE *fopen_noinh_readbin(char *filename)
return NULL;
}
#ifdef HAVE_FD_CLOEXEC
{
int fdflags = fcntl(fd_tmp, F_GETFD);
if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0) {
(void)fcntl(fd_tmp, F_SETFD, fdflags | FD_CLOEXEC);
}
}
#endif
(void)os_set_cloexec(fd_tmp);
return fdopen(fd_tmp, READBIN);
}