diff options
author | Sven Eden <yamakuzure@gmx.net> | 2017-04-27 11:30:28 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-05-17 15:22:16 +0200 |
commit | 66ecc207e203db5434610395cd04c40ae8727b58 (patch) | |
tree | 4808a261a6e58dcdbc9e8616f18cce65b2a49b83 /src/basic/process-util.c | |
parent | 4f8a2329ef626675895974d53a6afad68a0d255a (diff) |
Prep v229: Add missing fixes from upstream [1/6] src/basic
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r-- | src/basic/process-util.c | 41 |
1 files changed, 40 insertions, 1 deletions
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 <http://www.gnu.org/licenses/>. ***/ -#include <assert.h> #include <ctype.h> #include <errno.h> +#include <limits.h> +#include <linux/oom.h> #include <sched.h> #include <signal.h> #include <stdbool.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <sys/personality.h> #include <sys/prctl.h> #include <sys/types.h> #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" @@ -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", |