Ensure that the TTY file descriptor is greater than or equal to 10 so that
it doesn't interfere with the user's redirections. PR: 47136 MFC after: 1 week
This commit is contained in:
parent
273be50650
commit
29dbde6d3c
@ -126,9 +126,22 @@ setjobctl(int on)
|
||||
i = 0;
|
||||
while (i <= 2 && !isatty(i))
|
||||
i++;
|
||||
if (i > 2 || (ttyfd = dup(i)) < 0)
|
||||
if (i > 2 || (ttyfd = fcntl(i, F_DUPFD, 10)) < 0)
|
||||
goto out;
|
||||
}
|
||||
if (ttyfd < 10) {
|
||||
/*
|
||||
* Keep our TTY file descriptor out of the way of
|
||||
* the user's redirections.
|
||||
*/
|
||||
if ((i = fcntl(ttyfd, F_DUPFD, 10)) < 0) {
|
||||
close(ttyfd);
|
||||
ttyfd = -1;
|
||||
goto out;
|
||||
}
|
||||
close(ttyfd);
|
||||
ttyfd = i;
|
||||
}
|
||||
if (fcntl(ttyfd, F_SETFD, FD_CLOEXEC) < 0) {
|
||||
close(ttyfd);
|
||||
ttyfd = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user