[JOBS] Do not close stderr when /dev/tty fails to open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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@xxxxxxxxxxxxxxxxxxx>

diff --git a/ChangeLog b/ChangeLog
index d87e5d4..dcb7182 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 	* Fix dowait signal race.
 	* Remove EXSIG.
+	* Do not close stderr when /dev/tty fails to open.
 
 2009-01-14  Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
 
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 */
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux