I've got a C++ application which connects over a USB serial link to a microprocessor, (similar to an Arduino). I use termios.h
as my serial wrapper.
I'm debugging using cgdb
on Mac OS X 10.7.3
.
When I:
cgdb build/my-process
kill
inside cgdb
the process hangs. cgdb
refuses to ever kill the process - just sits there. I'm fairly sure this is because if I kill
from halfway through the application, I never release the /dev/ttyUSB
device that I'm accessing the microcontroller through. I'm not sure if something gets locked and never unlocked, but cgdb
never exits.
I've tried:
ps aux | grep 'my-process',
kill -9 [pid]`. ps aux | grep cgdb
, kill -9 [pid]
. sudo
versions of the above. Nothing kills either cgdb
or the process running in it.
If I remove the USB cable (terminate connection to microprocessor), (I thought that might crash the crashed process), I start seeing ~50% available CPU being used (not sure on what), and everything locks up. I don't manage to crash the application.
How do you: (a) exit cleanly without locking everything up from cgdb
or gdb
while in the middle of debugging a process, or (b) kill / cleanly (although 'cleanly' would just be icing on the cake) stop a process that's stopped while you're debugging it that isn't responding to kill -9
without rebooting?
You can't kill a process that's in an I/O wait. That's been true for most if not all Unix kernels from the dawn of the epoch.
It sounds like a debugger (or any process that's ptrace
ing another) that's stuck in an I/O wait can't be killed, either.