From patchwork Thu Jul 23 14:58:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel,master|dunfell|zeus] knotty: ignore pipe errors From: Mikko Rapeli X-Patchwork-Id: 174652 Message-Id: <20200723145812.14029-1-mikko.rapeli@bmw.de> To: bitbake-devel@lists.openembedded.org Cc: Mikko Rapeli Date: Thu, 23 Jul 2020 17:58:12 +0300 Piping bitbake output to another process like less currently results in an ugly error if the other end of pipe exits before bitbake has written all output to it. For example with "bitbake -e linux-yocto | less" and pressing q to quit less results in: Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/home/mcfrisk/src/yocto/poky/bitbake/lib/bb/event.py", line 133, in print_ui_queue sys.stdout.flush() BrokenPipeError: [Errno 32] Broken pipe Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='UTF-8'> BrokenPipeError: [Errno 32] Broken pipe Fix is to use default signal handler for pipe signal. It's perfectly normal that on Unix systems the other end of pipe gets killed before all data is written. In some cases there seems to also be a loop which results in a large number of "[Errno 32] Broken pipe" messages printed to console until knotty process is killed. I think this also fixes those cases. This patch applies to master, dunfell and zeus branches. Signed-off-by: Mikko Rapeli --- bitbake/lib/bb/ui/knotty.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 87e873d644..56ac41d0f9 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py @@ -29,6 +29,9 @@ featureSet = [bb.cooker.CookerFeatures.SEND_SANITYEVENTS] logger = logging.getLogger("BitBake") interactive = sys.stdout.isatty() +# ignore pipe errors since they are normal +signal.signal(signal.SIGPIPE, signal.SIG_DFL) + class BBProgress(progressbar.ProgressBar): def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None): self.msg = msg