summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-26 14:50:43 +0100
committerLennart Poettering <lennart@poettering.net>2016-01-26 14:50:43 +0100
commit590e0ac4bd42420d69d150a7aa7fb016693ea1ac (patch)
tree3a146eeb50967d737fc8aaedcf3f3d128ea2f32d /src/basic
parent1d35b2d6e25ba100c903f02c92c67389e67bb913 (diff)
parent1359fffa573f42463e3b369df5e57b0c33821a61 (diff)
Merge pull request #2441 from msekletar/killing-spree-excluded-log-v3
shutdown: complain if process excluded from killing spree runs of the same rootfs as PID1 (v3)
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/process-util.c12
-rw-r--r--src/basic/process-util.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 4341d0093f..189ef9ab60 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -48,6 +48,7 @@
#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 +638,17 @@ bool pid_is_alive(pid_t pid) {
return true;
}
+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");
+}
+
bool is_main_thread(void) {
static thread_local int cached = 0;
diff --git a/src/basic/process-util.h b/src/basic/process-util.h
index ac4d05e65f..f5d193e762 100644
--- a/src/basic/process-util.h
+++ b/src/basic/process-util.h
@@ -70,6 +70,7 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value);
bool pid_is_alive(pid_t pid);
bool pid_is_unwaited(pid_t pid);
+int pid_from_same_root_fs(pid_t pid);
bool is_main_thread(void);