进程在调试器中崩溃;我怎么杀掉它
我有一个 C++ 应用程序,它通过 USB 串行链路连接到微处理器(类似于 Arduino)。我使用 termios.h
作为我的串行包装器。
我正在 Mac OS X 10.7.3
上使用 cgdb
进行调试。
当我:
cgdb build/my-process
- 设置一些断点等,进行一些调试
- 查找错误,或尝试使用
kill<退出仍在运行的进程 /code> 在
cgdb
内,
进程挂起。 cgdb
拒绝终止该进程 - 只是坐在那里。我相当确信这是因为如果我在应用程序中途kill
,我永远不会释放我的/dev/ttyUSB
设备m 通过访问微控制器。我不确定是否有东西被锁定并且从未解锁,但 cgdb 永远不会退出。
我尝试过:
- 基本中断:Ctrl+C
ps aux | grep '我的进程',kill -9 [pid]`。
- PS 辅助 | grep cgdb,
kill -9 [pid]
。 - 上述的
sudo
版本。
没有什么会杀死 cgdb
或其中运行的进程。
如果我拔掉 USB 电缆(终止与微处理器的连接)(我认为这可能会使崩溃的进程崩溃),我开始看到大约 50% 的可用 CPU 正在使用(不确定是什么),并且一切都会锁定。我没有设法使应用程序崩溃。
您如何:(a)干净地退出而不在执行过程中锁定cgdb
或gdb
中的所有内容调试进程,或 (b) 杀死/干净地(尽管“干净地”只是锦上添花)停止在调试时停止的进程不是< /em> 响应 kill -9
无需重新启动?
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
- Set some breakpoints, etc, do some debugging
- Find a bug, or try to exit the still running process using
kill
insidecgdb
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:
- Basic interrupts: Ctrl+C
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法终止处于 I/O 等待状态的进程。从这个时代开始,对于大多数(如果不是全部)Unix 内核来说都是如此。
听起来好像陷入 I/O 等待的调试器(或任何
ptrace
ing 另一个进程)也无法被终止。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.ptrace 或 pgrep
我会尝试“pgrep -l cgdb”,非常方便地列出 pid...
ptrace or pgrep
I would try "pgrep -l cgdb" very handy for listing the pid...