chiark / gitweb /
Prep v227: Clean up various *-util.[hc] files
[elogind.git] / src / basic / process-util.c
index 07469871704e586700a3894b5392053d0f85b5b9..8a1f54db81b61fd6949401cb81b389e4b9942b54 100644 (file)
@@ -181,10 +181,10 @@ int is_kernel_thread(pid_t pid) {
         bool eof;
         FILE *f;
 
-        if (pid == 0)
+        if (pid == 0 || pid == 1) /* pid 1, and we ourselves certainly aren't a kernel thread */
                 return 0;
 
-        assert(pid > 0);
+        assert(pid > 1);
 
         p = procfs_file_alloca(pid, "cmdline");
         f = fopen(p, "re");
@@ -217,7 +217,7 @@ int get_process_capeff(pid_t pid, char **capeff) {
 
         p = procfs_file_alloca(pid, "status");
 
-        r = get_status_field(p, "\nCapEff:", capeff);
+        r = get_proc_field(p, "CapEff", WHITESPACE, capeff);
         if (r == -ENOENT)
                 return -ESRCH;
 
@@ -368,7 +368,6 @@ int get_process_environ(pid_t pid, char **env) {
 
         return 0;
 }
-#endif // 0
 
 int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
         int r;
@@ -414,6 +413,7 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
 
         return 0;
 }
+#endif // 0
 
 int wait_for_terminate(pid_t pid, siginfo_t *status) {
         siginfo_t dummy;