aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Xu <yang.xu@mediatek.com>2024-02-02 09:36:02 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-03-21 12:39:25 +0000
commit08f3e677d6af27a41a918aaa9da9c1c9b20a0b95 (patch)
tree77eb4ad624e569471f087d312aa47644db9d7ece
parenta029bfe96c6542f178720c72a772b7ede9898118 (diff)
downloadbitbake-08f3e677d6af27a41a918aaa9da9c1c9b20a0b95.tar.gz
bitbake-worker: Fix silent hang issue caused by unexpected stdout content
This patch addresses an issue in bitbake-worker where stdout, reserved for status reporting, is improperly accessed by child processes. The problem occurs during the execution of parseRecipe, which calls anonymous functions. If these functions use print-like operations, they can inadvertently output data to stdout. This unexpected data can cause the runqueue to hang silently, if the stdout buffer is flushed before exec_task is executed. To prevent this, the patch redirects stdout to /dev/null and ensures it is flushed prior to the execution of exec_task. Signed-off-by: Yang Xu <yang.xu@mediatek.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbin/bitbake-worker12
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/bitbake-worker b/bin/bitbake-worker
index 577651386..e8073f2ac 100755
--- a/bin/bitbake-worker
+++ b/bin/bitbake-worker
@@ -237,9 +237,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
# Let SIGHUP exit as SIGTERM
signal.signal(signal.SIGHUP, sigterm_handler)
- # No stdin
- newsi = os.open(os.devnull, os.O_RDWR)
- os.dup2(newsi, sys.stdin.fileno())
+ # No stdin & stdout
+ # stdout is used as a status report channel and must not be used by child processes.
+ dumbio = os.open(os.devnull, os.O_RDWR)
+ os.dup2(dumbio, sys.stdin.fileno())
+ os.dup2(dumbio, sys.stdout.fileno())
if umask is not None:
os.umask(umask)
@@ -305,6 +307,10 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
if not quieterrors:
logger.critical(traceback.format_exc())
os._exit(1)
+
+ sys.stdout.flush()
+ sys.stderr.flush()
+
try:
if dry_run:
return 0