summaryrefslogtreecommitdiff
path: root/src/core/main.c
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2016-01-19 15:48:45 +0000
committerEvgeny Vereshchagin <evvers@ya.ru>2016-01-21 01:32:05 +0000
commitdcadc9671c5ff0e4c1e7b6385f63a84387279f93 (patch)
treec5ed2c6cdcda8785ecca31663b2f46c390fde9ea /src/core/main.c
parent91c4b6db7840e68e4d7a019c3cb4d5d60d2a65c7 (diff)
core: add valgrind helper for daemon-reexec
Inspired by https://github.com/systemd/systemd/issues/2187#issuecomment-165587140
Diffstat (limited to 'src/core/main.c')
-rw-r--r--src/core/main.c9
1 files changed, 9 insertions, 0 deletions
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);
}