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=94ca0401d097e0e22970b8957d39df081936efef;hb=07045a1a92c839fd2af80bd0c060a595021bc3b3;hpb=eaca07ccfdf5d7dabc50afc7e539c2413dd69d3e diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 94ca0401d..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" @@ -185,8 +194,7 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char * return 0; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind void rename_process(const char name[8]) { assert(name); @@ -251,8 +259,7 @@ int is_kernel_thread(pid_t pid) { return 0; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind int get_process_capeff(pid_t pid, char **capeff) { const char *p; int r; @@ -304,8 +311,7 @@ int get_process_exe(pid_t pid, char **name) { return 0; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind static int get_process_id(pid_t pid, const char *field, uid_t *uid) { _cleanup_fclose_ FILE *f = NULL; char line[LINE_MAX]; @@ -537,8 +543,7 @@ void sigkill_wait(pid_t *pid) { (void) wait_for_terminate(*pid, NULL); } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind int kill_and_sigcont(pid_t pid, int sig) { int r; @@ -641,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; @@ -650,8 +668,7 @@ bool is_main_thread(void) { return cached > 0; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind noreturn void freeze(void) { /* Make sure nobody waits for us on a socket anymore */ @@ -739,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",