diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-02-01 18:27:11 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-03-13 05:51:39 +0300 |
commit | 6e60e8b2b2bab889379b380a28a167a0edd9d1d3 (patch) | |
tree | f12f54d5ba8e74e67e5fad3651a1e125bb8f4191 /import-layers/yocto-poky/bitbake/lib/prserv | |
parent | 509842add85b53e13164c1569a1fd43d5b8d91c5 (diff) | |
download | openbmc-6e60e8b2b2bab889379b380a28a167a0edd9d1d3.tar.xz |
Yocto 2.3
Move OpenBMC to Yocto 2.3(pyro).
Tested: Built and verified Witherspoon and Palmetto images
Change-Id: I50744030e771f4850afc2a93a10d3507e76d36bc
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Resolves: openbmc/openbmc#2461
Diffstat (limited to 'import-layers/yocto-poky/bitbake/lib/prserv')
-rw-r--r-- | import-layers/yocto-poky/bitbake/lib/prserv/serv.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/import-layers/yocto-poky/bitbake/lib/prserv/serv.py b/import-layers/yocto-poky/bitbake/lib/prserv/serv.py index cafcc820c..a7efa58bc 100644 --- a/import-layers/yocto-poky/bitbake/lib/prserv/serv.py +++ b/import-layers/yocto-poky/bitbake/lib/prserv/serv.py @@ -5,12 +5,7 @@ import threading import queue import socket import io - -try: - import sqlite3 -except ImportError: - from pysqlite2 import dbapi2 as sqlite3 - +import sqlite3 import bb.server.xmlrpc import prserv import prserv.db @@ -242,12 +237,25 @@ class PRServer(SimpleXMLRPCServer): sys.stdout.flush() sys.stderr.flush() + + # We could be called from a python thread with io.StringIO as + # stdout/stderr or it could be 'real' unix fd forking where we need + # to physically close the fds to prevent the program launching us from + # potentially hanging on a pipe. Handle both cases. si = open('/dev/null', 'r') + try: + os.dup2(si.fileno(),sys.stdin.fileno()) + except (AttributeError, io.UnsupportedOperation): + sys.stdin = si so = open(self.logfile, 'a+') - se = so - os.dup2(si.fileno(),sys.stdin.fileno()) - os.dup2(so.fileno(),sys.stdout.fileno()) - os.dup2(se.fileno(),sys.stderr.fileno()) + try: + os.dup2(so.fileno(),sys.stdout.fileno()) + except (AttributeError, io.UnsupportedOperation): + sys.stdout = so + try: + os.dup2(so.fileno(),sys.stderr.fileno()) + except (AttributeError, io.UnsupportedOperation): + sys.stderr = so # Clear out all log handlers prior to the fork() to avoid calling # event handlers not part of the PRserver @@ -420,7 +428,7 @@ class PRServiceConfigError(Exception): def auto_start(d): global singleton - host_params = list(filter(None, (d.getVar('PRSERV_HOST', True) or '').split(':'))) + host_params = list(filter(None, (d.getVar('PRSERV_HOST') or '').split(':'))) if not host_params: return None @@ -431,7 +439,7 @@ def auto_start(d): if is_local_special(host_params[0], int(host_params[1])) and not singleton: import bb.utils - cachedir = (d.getVar("PERSISTENT_DIR", True) or d.getVar("CACHE", True)) + cachedir = (d.getVar("PERSISTENT_DIR") or d.getVar("CACHE")) if not cachedir: logger.critical("Please set the 'PERSISTENT_DIR' or 'CACHE' variable") raise PRServiceConfigError |