summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/prserv/serv.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 350b085a51..d9b602f14c 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -242,12 +242,25 @@ class PRServer(SimpleXMLRPCServer):
242 242
243 sys.stdout.flush() 243 sys.stdout.flush()
244 sys.stderr.flush() 244 sys.stderr.flush()
245
246 # We could be called from a python thread with io.StringIO as
247 # stdout/stderr or it could be 'real' unix fd forking where we need
248 # to physically close the fds to prevent the program launching us from
249 # potentially hanging on a pipe. Handle both cases.
245 si = open('/dev/null', 'r') 250 si = open('/dev/null', 'r')
251 try:
252 os.dup2(si.fileno(),sys.stdin.fileno())
253 except (AttributeError, io.UnsupportedOperation):
254 sys.stdin = si
246 so = open(self.logfile, 'a+') 255 so = open(self.logfile, 'a+')
247 se = so 256 try:
248 os.dup2(si.fileno(),sys.stdin.fileno()) 257 os.dup2(so.fileno(),sys.stdout.fileno())
249 os.dup2(so.fileno(),sys.stdout.fileno()) 258 except (AttributeError, io.UnsupportedOperation):
250 os.dup2(se.fileno(),sys.stderr.fileno()) 259 sys.stdout = so
260 try:
261 os.dup2(so.fileno(),sys.stderr.fileno())
262 except (AttributeError, io.UnsupportedOperation):
263 sys.stderr = so
251 264
252 # Clear out all log handlers prior to the fork() to avoid calling 265 # Clear out all log handlers prior to the fork() to avoid calling
253 # event handlers not part of the PRserver 266 # event handlers not part of the PRserver