diff options
author | Daniel Mack <github@zonque.org> | 2016-01-21 11:51:37 +0100 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2016-01-21 11:51:37 +0100 |
commit | 127a45c36f3c4ec04b6a7e3067b127ecb5894fdf (patch) | |
tree | d1c215da96e4fde3a19aaec4cf2002067f93679d /src/basic | |
parent | 9ecbcdffdf15bb76f57e8c403070dd43e206858d (diff) | |
parent | dcadc9671c5ff0e4c1e7b6385f63a84387279f93 (diff) |
Merge pull request #2371 from evverx/add-valgrind-helper-for-daemon-reexec
core: add valgrind helper for daemon-reexec
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/process-util.c | 20 | ||||
-rw-r--r-- | src/basic/process-util.h | 2 |
2 files changed, 22 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", diff --git a/src/basic/process-util.h b/src/basic/process-util.h index f4c4437624..ac4d05e65f 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -98,3 +98,5 @@ int sched_policy_from_string(const char *s); #define PTR_TO_PID(p) ((pid_t) ((uintptr_t) p)) #define PID_TO_PTR(p) ((void*) ((uintptr_t) p)) + +void valgrind_summary_hack(void); |