How do you kill PDB and the program it's running, similar to LLDB's proc kill; exit
or exit (y)
commands?
Ctrl+D isn't working and all the questions I see on here are how to exit while keeping the program running. However, I'm sitting in a PDB session and I found a bug that is causing an endless loop, and while there are indeed other things I can do to kill the program I figured I'd ask what the PDB command is to do it.
The pdb command to kill the program is q
, or quit
. Quoting the docs:
q(uit)
Quit from the debugger. The program being executed is aborted.
When q
is not enough to stop the loop (perhaps you have a misbehaving except
block), you may need to use os._exit()
, a low-level command which terminates the process immediately. (q
and sys.exit
work by throwing exceptions - bdb.BdbQuit
for q
and SystemExit
for sys.exit
.) os._exit
will prevent any finally
blocks or __exit__
methods from running, so you may have to deal with data corruption or data loss.
Ex: import os; os._exit(0)
(https://stackoverflow.com/a/38511414/2036148)
Or try hitting Ctrl+\
(kill) in the terminal.