summaryrefslogtreecommitdiffstats
path: root/bitbake/bin/bitbake-worker
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-22 16:26:46 +0000
commit64057e6b153c387eafa0c4c8e0dab2779df45003 (patch)
tree93f1eaa4162b88d95cc8db73c5677c84ec2fe47c /bitbake/bin/bitbake-worker
parent9504df41f9e1c64014436a46abf058c5d3f42d3f (diff)
downloadpoky-64057e6b153c387eafa0c4c8e0dab2779df45003.tar.gz
bitbake: 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. (Bitbake rev: 08f3e677d6af27a41a918aaa9da9c1c9b20a0b95) Signed-off-by: Yang Xu <yang.xu@mediatek.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin/bitbake-worker')
-rwxr-xr-xbitbake/bin/bitbake-worker12
1 files changed, 9 insertions, 3 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index 577651386f..e8073f2ac3 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -237,9 +237,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
237 # Let SIGHUP exit as SIGTERM 237 # Let SIGHUP exit as SIGTERM
238 signal.signal(signal.SIGHUP, sigterm_handler) 238 signal.signal(signal.SIGHUP, sigterm_handler)
239 239
240 # No stdin 240 # No stdin & stdout
241 newsi = os.open(os.devnull, os.O_RDWR) 241 # stdout is used as a status report channel and must not be used by child processes.
242 os.dup2(newsi, sys.stdin.fileno()) 242 dumbio = os.open(os.devnull, os.O_RDWR)
243 os.dup2(dumbio, sys.stdin.fileno())
244 os.dup2(dumbio, sys.stdout.fileno())
243 245
244 if umask is not None: 246 if umask is not None:
245 os.umask(umask) 247 os.umask(umask)
@@ -305,6 +307,10 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
305 if not quieterrors: 307 if not quieterrors:
306 logger.critical(traceback.format_exc()) 308 logger.critical(traceback.format_exc())
307 os._exit(1) 309 os._exit(1)
310
311 sys.stdout.flush()
312 sys.stderr.flush()
313
308 try: 314 try:
309 if dry_run: 315 if dry_run:
310 return 0 316 return 0