【发布时间】:2011-09-06 14:17:16
【问题描述】:
杀死 valgrind 进程本身不会留下关于内部进程执行的报告。
是否可以向 valgrind 内部运行的进程发送终止信号?
【问题讨论】:
标签: valgrind
杀死 valgrind 进程本身不会留下关于内部进程执行的报告。
是否可以向 valgrind 内部运行的进程发送终止信号?
【问题讨论】:
标签: valgrind
没有“内部进程”,因为 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 没有机会做任何事情。
【讨论】:
kill -SIGTERM,但是 valgrind 需要很长时间才能停止(约 10 分钟),所以我怀疑它不起作用。感谢您的回答。