[英]How to send a signal to a process to cause call to exit() and terminate
I have a program that only generates the output when it returns normally or when it calls the exit()
function (I'm trying to use gcov
on a C program). 我有一个仅在正常返回或调用
exit()
函数时才生成输出的程序(我正在尝试在C程序上使用gcov
)。 On a special input my program hangs in an infinite loop so I have to terminate it by sending termination signal. 在特殊输入上,我的程序挂在无限循环中,因此我必须通过发送终止信号来终止它。 In this situation it won't produce the output I need since it wouldn't call
exit()
. 在这种情况下,它不会产生我需要的输出,因为它不会调用
exit()
。
Is there any way that I can force a running program to call exit()
and terminate without touching the source code and writing a signal handler? 有什么方法可以迫使正在运行的程序调用
exit()
并终止而不触及源代码和编写信号处理程序?
正如评论中所建议的那样,我在gdb
执行了我的程序,并在收到信号后手动调用exit()
,它的工作方式就像魅力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.