summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-02-22 19:29:48 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2009-02-22 19:29:48 +0800
commitfcc4134a7b76d82d39dea635c41ec593a41d6d19 (patch)
treea844ae59b0f60d5215260d8b7a10454b4062e627 /src
parent[SIGNAL] Remove EXSIG (diff)
downloaddash-fcc4134a7b76d82d39dea635c41ec593a41d6d19.tar.gz
dash-fcc4134a7b76d82d39dea635c41ec593a41d6d19.zip
[JOBS] Do not close stderr when /dev/tty fails to open
As it stands if we fail to open /dev/tty we end up closing stderr
after saving it at a higher fd.

Thanks to David van Gorkom for reporting this.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'src')
-rw-r--r--src/jobs.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/jobs.c b/src/jobs.c
index 69a84f7..b1ab7ab 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -195,6 +195,9 @@ setjobctl(int on)
 			while (!isatty(fd))
 				if (--fd < 0)
 					goto out;
+			fd = dup(fd);
+			if (fd < 0)
+				goto out;
 		}
 		fd = savefd(fd);
 		do { /* while we are in the background */