diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-06-27 20:38:23 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2009-06-27 20:38:23 +0800 |
commit | 6c0398654015de53269a2ef32eae3c7b560875dd (patch) | |
tree | bbfe4fd062df4cc0d0bb9d2c589f135a0de9e42e /src/jobs.c | |
parent | [MAN] Update manual page to differentiate dash from ash (diff) | |
download | dash-6c0398654015de53269a2ef32eae3c7b560875dd.tar.gz dash-6c0398654015de53269a2ef32eae3c7b560875dd.zip |
[REDIR] Fix incorrect savefd conversions
When I added savefd we may end up closing stderr if that is how we get to the tty. This patch fixes by adding a second argument to indicate what fd should be closed which lets jobs.c get around the problem. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r-- | src/jobs.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/jobs.c b/src/jobs.c index b1ab7ab..a4fada0 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -189,17 +189,15 @@ setjobctl(int on) if (on == jobctl || rootshell == 0) return; if (on) { - fd = open(_PATH_TTY, O_RDWR); + int ofd; + ofd = fd = open(_PATH_TTY, O_RDWR); if (fd < 0) { fd += 3; while (!isatty(fd)) if (--fd < 0) goto out; - fd = dup(fd); - if (fd < 0) - goto out; } - fd = savefd(fd); + fd = savefd(fd, ofd); do { /* while we are in the background */ if ((pgrp = tcgetpgrp(fd)) < 0) { out: |