From dcadc9671c5ff0e4c1e7b6385f63a84387279f93 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Tue, 19 Jan 2016 15:48:45 +0000 Subject: core: add valgrind helper for daemon-reexec Inspired by https://github.com/systemd/systemd/issues/2187#issuecomment-165587140 --- src/core/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/core') diff --git a/src/core/main.c b/src/core/main.c index 2f9094f03a..27ba6af031 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1968,6 +1968,15 @@ finish: (void) clearenv(); assert(i <= args_size); + + /* + * We want valgrind to print its memory usage summary before reexecution. + * Valgrind won't do this is on its own on exec(), but it will do it on exit(). + * Hence, to ensure we get a summary here, fork() off a child, let it exit() cleanly, + * so that it prints the summary, and wait() for it in the parent, before proceeding into the exec(). + */ + valgrind_summary_hack(); + (void) execv(args[0], (char* const*) args); } -- cgit v1.2.3-54-g00ecf