[6/6] cooker: Pass SIGINT to parsing processes at shutdown

Message ID 20220326203458.1391301-6-richard.purdie@linuxfoundation.org
State New
Headers show
Series [1/6] cooker: Fix exception handling in parsers | expand

Commit Message

Richard Purdie March 26, 2022, 8:34 p.m. UTC
To try and improve shutdown, sent SIGINT to parsing processes now it
is handled safely around locks, perhaps avoiding the need for the more
risky SIGTERM.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/cooker.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 4b8b18a68d..bd7ab8ac3c 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -2146,7 +2146,7 @@  class CookerParser(object):
             def init():
                 signal.signal(signal.SIGTERM, signal.SIG_DFL)
                 signal.signal(signal.SIGHUP, signal.SIG_DFL)
-                signal.signal(signal.SIGINT, signal.SIG_IGN)
+                signal.signal(signal.SIGINT, signal.default_int_handler)
                 bb.utils.set_process_name(multiprocessing.current_process().name)
                 multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, exitpriority=1)
                 multiprocessing.util.Finalize(None, bb.fetch.fetcher_parse_save, exitpriority=1)
@@ -2194,6 +2194,9 @@  class CookerParser(object):
             except queue.Empty:
                 break
 
+        for process in self.processes:
+            os.kill(process.pid, signal.SIGINT)
+
         for process in self.processes:
             if force:
                 process.join(.1)