This is somewhat related to gdb set overwrite logging on should overwrite gdb.txt correct? .

Let's say I'm running a session of some application. For example purposes, let me take the example of qbittorrent again.

As shared before this is how a run happens -

$ gdb qbittorrent 
(gdb) set logging overwrite on 
(gdb) set logging on 
(gdb) set pagination 0
(gdb) run

one way I know is exiting the application gracefully but sometimes the application hangs/takes too much time or simply doesn't respond.

Then the only option which remains with me is using CTRL+C which if I understand correctly kills the underlying application, in our example qbittorrent and then am able to quit gdb by means of

(gdb) quit

Is/would there be any other way of quitting the application and still let the gdb session keep running or the only way is the crude way I mentioned above.

AFAI know killing an application process should be the last solution and not the first.

  • When running under gdb under default settings, Ctrl-C does not kill the application, just breaks into the debugger, where you can decide what to do. Use cont to "swallow" the signal, and the application continues undisturbed. Or use signal 2 to pass the SIGINT (2) to the application. Or use kill to kill the application. Oct 21, 2017 at 7:43

1 Answer 1


You can use signals for this. Before you start your program, set up USR1 or USR2 to break gdb without affecting the program:

handle SIGUSR1 nopass

Then you can run your program, and when you need to stop it, run kill -USR1 from another shell with the appropriate (child) pid. gdb will pause the application, and you can then add breakpoints, examine state etc., and if you want to, continue the execution with cont.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .