5f234b1
commit fcc4134a7b76d82d39dea635c41ec593a41d6d19
5f234b1
Author: Herbert Xu <herbert@gondor.apana.org.au>
5f234b1
Date:   Sun Feb 22 19:29:48 2009 +0800
5f234b1
5f234b1
    [JOBS] Do not close stderr when /dev/tty fails to open
5f234b1
    
5f234b1
    As it stands if we fail to open /dev/tty we end up closing stderr
5f234b1
    after saving it at a higher fd.
5f234b1
    
5f234b1
    Thanks to David van Gorkom for reporting this.
5f234b1
    
5f234b1
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
5f234b1
5f234b1
diff --git a/src/jobs.c b/src/jobs.c
5f234b1
index 69a84f7..b1ab7ab 100644
5f234b1
--- a/src/jobs.c
5f234b1
+++ b/src/jobs.c
5f234b1
@@ -195,6 +195,9 @@ setjobctl(int on)
5f234b1
 			while (!isatty(fd))
5f234b1
 				if (--fd < 0)
5f234b1
 					goto out;
5f234b1
+			fd = dup(fd);
5f234b1
+			if (fd < 0)
5f234b1
+				goto out;
5f234b1
 		}
5f234b1
 		fd = savefd(fd);
5f234b1
 		do { /* while we are in the background */