Skip to content

Commit 1b837f3

Browse files
authored
Merge pull request #87 from ClangBuiltLinux/signals
boot-qemu.py: fix ctrl+c in gdb
2 parents 64b7d42 + 4beafc6 commit 1b837f3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

boot-qemu.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ def launch_qemu(cfg):
755755

756756
if gdb:
757757
utils.check_cmd(gdb_bin)
758+
qemu_cmd += ["-s", "-S"]
758759

759760
while True:
760761
utils.check_cmd("lsof")
@@ -766,12 +767,18 @@ def launch_qemu(cfg):
766767
utils.die("Port 1234 is already in use, is QEMU running?")
767768

768769
utils.green("Starting QEMU with GDB connection on port 1234...")
769-
with subprocess.Popen(qemu_cmd + ["-s", "-S"]) as qemu_process:
770+
with subprocess.Popen(qemu_cmd,
771+
preexec_fn=os.setpgrp) as qemu_process:
770772
utils.green("Starting GDB...")
771773
gdb_cmd = [gdb_bin]
772774
gdb_cmd += [kernel_location.joinpath("vmlinux")]
773775
gdb_cmd += ["-ex", "target remote :1234"]
774-
subprocess.run(gdb_cmd, check=False)
776+
777+
with subprocess.Popen(gdb_cmd) as gdb_process:
778+
try:
779+
gdb_process.wait()
780+
except KeyboardInterrupt:
781+
pass
775782

776783
utils.red("Killing QEMU...")
777784
qemu_process.kill()

0 commit comments

Comments
 (0)