diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-11-20 22:11:10 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-20 22:12:47 +0100 |
commit | 54b434b1b5055f934230fe04fad35b01642b8488 (patch) | |
tree | adfaa55b25f34b24170b4f979290202a5b0a8271 /src | |
parent | 420c7379fb96a188459690a634d0fede55721183 (diff) |
valgrind: make running PID 1 in valgrind useful
Since valgrind only generates useful output on exit() (rather than
exec()) we need to explicitly exit when valgrind is detected.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/main.c b/src/core/main.c index f342cdd289..4d4f6e8f4c 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -32,6 +32,10 @@ #include <sys/prctl.h> #include <sys/mount.h> +#ifdef HAVE_VALGRIND_VALGRIND_H +#include <valgrind/valgrind.h> +#endif + #include "sd-daemon.h" #include "sd-messages.h" #include "sd-bus.h" @@ -1830,6 +1834,15 @@ finish: if (fds) fdset_free(fds); +#ifdef HAVE_VALGRIND_VALGRIND_H + /* If we are PID 1 and running under valgrind, then let's exit + * here explicitly. valgrind will only generate nice output on + * exit(), not on exec(), hence let's do the former not the + * latter here. */ + if (getpid() == 1 && RUNNING_ON_VALGRIND) + return 0; +#endif + if (shutdown_verb) { const char * command_line[] = { SYSTEMD_SHUTDOWN_BINARY_PATH, |