终止 valgrind 内运行的进程

发布于 2024-12-03 05:05:23 字数 76 浏览 0 评论 0原文

终止 valgrind 进程本身不会留下有关内部进程执行的报告。

是否可以向 valgrind 内运行的进程发送终止信号?

Killing the valgrind process itself leaves no report on the inner process' execution.

Is it possible to send a terminate signal to a process running inside valgrind?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失眠症患者 2024-12-10 05:05:23

不存在“内部进程”,因为 valgrind 本身和它运行的客户端程序都在单个进程中执行。

发送到该进程的信号将正常传递到客户端程序。如果信号导致进程终止,则 valgrind 的正常退出处理程序将运行并(例如)报告任何泄漏。

因此,例如,如果我们在 sleep 命令上启动 valgrind:

bericote [~] % valgrind sleep 240
==9774== Memcheck, a memory error detector
==9774== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==9774== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==9774== Command: sleep 240
==9774== 

然后终止该命令:

bericote [~] % kill -TERM 9774

那么进程将退出并且 valgrind 的退出处理程序将运行:

==9774== 
==9774== HEAP SUMMARY:
==9774==     in use at exit: 0 bytes in 0 blocks
==9774==   total heap usage: 30 allocs, 30 frees, 3,667 bytes allocated
==9774== 
==9774== All heap blocks were freed -- no leaks are possible
==9774== 
==9774== For counts of detected and suppressed errors, rerun with: -v
==9774== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
[1]    9774 terminated  valgrind sleep 240

唯一的例外是 kill -9 ,如下所示如果进程在没有收到信号通知的情况下被内核杀死,那么 valgrind 就没有机会做任何事情。

There is no "inner process" as both valgrind itself and the client program it is running execute in a single process.

Signals sent to that process will be delivered to the client program as normal. If the signal causes the process to terinate then valgrind's normal exit handlers will run and (for example) report any leaks.

So, for example, if we start valgrind on a sleep command:

bericote [~] % valgrind sleep 240
==9774== Memcheck, a memory error detector
==9774== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==9774== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==9774== Command: sleep 240
==9774== 

then kill that command:

bericote [~] % kill -TERM 9774

then the process will exit and valgrind's exit handlers will run:

==9774== 
==9774== HEAP SUMMARY:
==9774==     in use at exit: 0 bytes in 0 blocks
==9774==   total heap usage: 30 allocs, 30 frees, 3,667 bytes allocated
==9774== 
==9774== All heap blocks were freed -- no leaks are possible
==9774== 
==9774== For counts of detected and suppressed errors, rerun with: -v
==9774== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
[1]    9774 terminated  valgrind sleep 240

The only exception would be for kill -9 as in that case the process is killed by the kernel without ever being informed of the signal so valgrind has no opportunity to do anything.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文