diff options
| author | Tim J. Robbins <tjr@FreeBSD.org> | 2003-02-04 02:39:40 +0000 |
|---|---|---|
| committer | Tim J. Robbins <tjr@FreeBSD.org> | 2003-02-04 02:39:40 +0000 |
| commit | 77b673b4cd44265c80886914aacf12f7f3c09512 (patch) | |
| tree | b85153f6650eebc635484c819185f254e6e87511 /bin | |
| parent | ae4a324683b40c55c1e88a2bb6df5594ebb861c4 (diff) | |
Notes
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/sh/jobs.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 89aecea490fb..6595b67305ee 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -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; |
