Sample Header Ad - 728x90

Override GDB taking over controlling terminal and its SIGINT

0 votes
0 answers
36 views
I have a Python script that is running subprocesses that calls gdb --batch. That script needs to handle Control-C (SIGINT). While one of the GDB subprocesses is running, if I send a Control-C on the terminal, rather than the signal going to the script it goes to GDB. After the GDB job(s) exit, Control-C then correctly will go to the script again. I believe this is because GDB is establishing itself as a controlling terminal. Then when GDB exits the controlling terminal (due to other IO etc) returns to the script. 1. Is there a way to tell GDB not to take the controlling terminal? I looked at the GDB sources and I don't see a way it can be told to do an open() with O_NOCTTY which I suspect would do this. I'm not willing to recompile GDB. Perhaps some hack using a pseudo-TTY somehow? 2. If not, is there a way for my script to "take back" the controlling terminal? Note GDB needs to continue to run in the other process. I suspect I could make a new subprocess, make that the process leader, then do a TTY open, which would make it the lead, then close the subprocess, would that work? I dislike this as a hack. Note I don't want to disassociate the subprocesses from the script's process group. Thanks
Asked by J Howe (1 rep)
Feb 1, 2025, 07:33 PM