summaryrefslogtreecommitdiffstats
path: root/scripts/kill-bb
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2019-08-02 02:32:32 -0700
committerRobert Yang <liezhi.yang@windriver.com>2019-08-02 18:23:58 +0800
commit6e12b495c74cfe8497e067fe1b4c4b823c6d4abe (patch)
tree9807812729ecaf989aa304f49e7ad78d8bcf0e61 /scripts/kill-bb
parentfc634c41e4b3fbaf29dc0104ae6b15757e77f60a (diff)
downloadopenembedded-core-contrib-6e12b495c74cfe8497e067fe1b4c4b823c6d4abe.tar.gz
kill-bb: Add it for killing abnormal bitbake processesrbt/kill-bb
There might be processes left after Ctr-C, e.g.: $ rm -f tmp/cache/default-glibc/qemux86/x86_64/ $ bitbake -p Press 'Ctrl-C' multiple times during parsing, then bitbake processes may not exit, and the worse is that we can't start bitbake again, we can't always reproduce this, but sometime. We can only use "ps ux" to find the processes and kill them one by one. This tool can kill all of them easily. Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Diffstat (limited to 'scripts/kill-bb')
-rwxr-xr-xscripts/kill-bb35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/kill-bb b/scripts/kill-bb
new file mode 100755
index 0000000000..0875b2c18c
--- /dev/null
+++ b/scripts/kill-bb
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+#
+# Kill bitbake processes if the process' cwd == cwd
+#
+# Copyright (c) 2019 Wind River Systems, Inc.
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import os
+import sys
+import re
+
+pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
+
+bb_pids = []
+cwd =os.getcwd()
+for pid in pids:
+ cmdline_path = os.path.join('/proc', pid, 'cmdline')
+ pid_cwd = os.path.join('/proc', pid, 'cwd')
+ if os.path.exists(cmdline_path) and os.path.exists(pid_cwd):
+ pid_cwd = os.readlink(pid_cwd)
+ with open(cmdline_path, 'r') as f:
+ cmdline = f.read()
+ # Kill the bitbake process if its cwd == cwd
+ if re.match('python3.*/bitbake/bin/bitbake', cmdline) and pid_cwd == cwd:
+ bb_pids.append(pid)
+
+if not bb_pids:
+ print('No bitbake processes found in current working dir')
+ sys.exit(0)
+
+for pid in bb_pids:
+ print('Killing %s' % pid)
+ os.kill(int(pid), 9)