diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2016-01-19 15:48:45 +0000 |
---|---|---|
committer | Evgeny Vereshchagin <evvers@ya.ru> | 2016-01-21 01:32:05 +0000 |
commit | dcadc9671c5ff0e4c1e7b6385f63a84387279f93 (patch) | |
tree | c5ed2c6cdcda8785ecca31663b2f46c390fde9ea /src/basic/process-util.c | |
parent | 91c4b6db7840e68e4d7a019c3cb4d5d60d2a65c7 (diff) |
core: add valgrind helper for daemon-reexec
Inspired by https://github.com/systemd/systemd/issues/2187#issuecomment-165587140
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r-- | src/basic/process-util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 4cc54a51fb..4341d0093f 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -33,6 +33,9 @@ #include <sys/wait.h> #include <syslog.h> #include <unistd.h> +#ifdef HAVE_VALGRIND_VALGRIND_H +#include <valgrind/valgrind.h> +#endif #include "alloc-util.h" #include "escape.h" @@ -730,6 +733,23 @@ const char* personality_to_string(unsigned long p) { return NULL; } +void valgrind_summary_hack(void) { +#ifdef HAVE_VALGRIND_VALGRIND_H + if (getpid() == 1 && RUNNING_ON_VALGRIND) { + pid_t pid; + pid = raw_clone(SIGCHLD, NULL); + if (pid < 0) + log_emergency_errno(errno, "Failed to fork off valgrind helper: %m"); + else if (pid == 0) + exit(EXIT_SUCCESS); + else { + log_info("Spawned valgrind helper as PID "PID_FMT".", pid); + (void) wait_for_terminate(pid, NULL); + } + } +#endif +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", |