Skip to content

Commit cd157ce

Browse files
userland_gdb: wait for process and dont die on SIGINT
Signed-off-by: Andy-Python-Programmer <[email protected]>
1 parent 1d57d88 commit cd157ce

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/gdb-debug-userland.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import os
55
import subprocess
6+
import signal
67

78

89
def gdb_main(program: str, is_lib: bool):
@@ -28,6 +29,14 @@ def gdb_main(program: str, is_lib: bool):
2829
gdb.execute("b main")
2930

3031

32+
def wait_for_process(process):
33+
try:
34+
process.wait()
35+
except KeyboardInterrupt:
36+
process.send_signal(signal.SIGINT)
37+
wait_for_process(process)
38+
39+
3140
if __name__ == "__main__":
3241
if os.getenv("IN_GDB") == "yes":
3342
import gdb
@@ -47,5 +56,5 @@ def gdb_main(program: str, is_lib: bool):
4756
process = subprocess.Popen(
4857
"gdb -tui -q -x tools/gdb-debug-userland.py", shell=True)
4958

50-
process.wait()
59+
wait_for_process(process)
5160
os.environ["IN_GDB"] = "no"

0 commit comments

Comments
 (0)