]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
cooker.py: Catch when stdout doesn't have a file descriptor
authorMariano Lopez <mariano.lopez@linux.intel.com>
Tue, 23 Aug 2016 07:06:11 +0000 (07:06 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 2 Sep 2016 15:29:36 +0000 (16:29 +0100)
Currently, there is a check to remove the TOSTOP attribute from
a tty to avoid hangs. It assumes that sys.stdout will have a
file descriptor and this is not always true, some IO classes
will throw exceptions when trying to get its file descriptor.

This will add a check for such cases and avoid throwing an
exception.

[YOCTO #10162]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/cooker.py

index d1ab4aa17bb8a6947ae96e877bf1fb24db7c75b5..b7d7a7ec216ac24809747a1f2c1735d5662264b1 100644 (file)
@@ -30,7 +30,7 @@ import logging
 import multiprocessing
 import sre_constants
 import threading
-from io import StringIO
+from io import StringIO, UnsupportedOperation
 from contextlib import closing
 from functools import wraps
 from collections import defaultdict, namedtuple
@@ -230,14 +230,17 @@ class BBCooker:
             pass
 
         # TOSTOP must not be set or our children will hang when they output
-        fd = sys.stdout.fileno()
-        if os.isatty(fd):
-            import termios
-            tcattr = termios.tcgetattr(fd)
-            if tcattr[3] & termios.TOSTOP:
-                buildlog.info("The terminal had the TOSTOP bit set, clearing...")
-                tcattr[3] = tcattr[3] & ~termios.TOSTOP
-                termios.tcsetattr(fd, termios.TCSANOW, tcattr)
+        try:
+            fd = sys.stdout.fileno()
+            if os.isatty(fd):
+                import termios
+                tcattr = termios.tcgetattr(fd)
+                if tcattr[3] & termios.TOSTOP:
+                    buildlog.info("The terminal had the TOSTOP bit set, clearing...")
+                    tcattr[3] = tcattr[3] & ~termios.TOSTOP
+                    termios.tcsetattr(fd, termios.TCSANOW, tcattr)
+        except UnsupportedOperation:
+            pass
 
         self.command = bb.command.Command(self)
         self.state = state.initial