X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Fprocess-util.c;h=550419d5ed608082bca14c7f7ae5e538a0f90f7b;hp=0c6a494e07931adcd70c7105c22f4d97f6cbd1a2;hb=07045a1a92c839fd2af80bd0c060a595021bc3b3;hpb=68def6bc80ba50ed3b3658d00799a3ec295c4d7a diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 0c6a494e0..550419d5e 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -17,19 +17,25 @@ along with systemd; If not, see . ***/ -#include #include #include +#include +#include #include #include #include #include +#include #include #include #include #include #include +#include #include +#ifdef HAVE_VALGRIND_VALGRIND_H +#include +#endif #include "alloc-util.h" #include "escape.h" @@ -38,8 +44,11 @@ #include "fs-util.h" //#include "ioprio.h" #include "log.h" +#include "macro.h" +#include "missing.h" #include "process-util.h" #include "signal-util.h" +//#include "stat-util.h" #include "string-table.h" #include "string-util.h" #include "user-util.h" @@ -637,6 +646,19 @@ bool pid_is_alive(pid_t pid) { return true; } +#if 0 /// UNNEEDED by elogind +int pid_from_same_root_fs(pid_t pid) { + const char *root; + + if (pid < 0) + return 0; + + root = procfs_file_alloca(pid, "root"); + + return files_same(root, "/proc/1/root"); +} +#endif // 0 + bool is_main_thread(void) { static thread_local int cached = 0; @@ -734,6 +756,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",