Open reberhardt7 opened 4 years ago
https://sourceware.org/gdb/current/onlinedocs/gdb/Signals.html
Would something like handle all nostop print pass
work?
Possibly, but I'm not sure. Normally, when you run a program under gdb and do ctrl+c, the program stops (this is reflected in the link you sent: "stop, print, pass for the erroneous signals"). However, in cplayground, the program isn't stopping at all; it just keeps on running.
GDB is running in MI (machine interface) mode in cplayground, and I'm guessing this has something to do with the behavior.
Normally, if you click the terminal and press ctrl+c, that will result in SIGINT being delivered to the user's process (killing it unless they've installed a signal handler). However, if the program is being run in debug mode, the program isn't killed. I think this is because run.py doesn't actually start the user's program directly (it starts gdb, which starts the user's program) and gdb is ignoring SIGINT. If that's true, it means that other keyboard-generated signals also aren't being delivered to the program. This is a problem, since cplayground is used to teach about signal handling, and I don't want students to have a confusing experience where things work one way normally and then work a different way when they start the debugger.
The fix will probably involve getting gdb to create a process group, placing the user's program in the process group, then putting that process group in the foreground using tcsetpgrp. I'm not sure -- this will take some investigation.