}
}
-int is_kernel_thread(pid_t pid) {
+int pid_is_kernel_thread(pid_t pid) {
_cleanup_free_ char *line = NULL;
unsigned long long flags;
size_t l, i;
return !!(flags & PF_KTHREAD);
}
+int pidref_is_kernel_thread(const PidRef *pid) {
+ int result, r;
+
+ if (!pidref_is_set(pid))
+ return -ESRCH;
+
+ result = pid_is_kernel_thread(pid->pid);
+ if (result < 0)
+ return result;
+
+ r = pidref_verify(pid); /* Verify that the PID wasn't reused since */
+ if (r < 0)
+ return r;
+
+ return result;
+}
+
int get_process_capeff(pid_t pid, char **ret) {
const char *p;
int r;
int kill_and_sigcont(pid_t pid, int sig);
-int is_kernel_thread(pid_t pid);
+int pid_is_kernel_thread(pid_t pid);
+int pidref_is_kernel_thread(const PidRef *pid);
int getenv_for_pid(pid_t pid, const char *field, char **_value);
g->n_tasks = 0;
while (cg_read_pid(f, &pid) > 0) {
- if (arg_count == COUNT_USERSPACE_PROCESSES && is_kernel_thread(pid) > 0)
+ if (arg_count == COUNT_USERSPACE_PROCESSES && pid_is_kernel_thread(pid) > 0)
continue;
g->n_tasks++;
if (r < 0)
return r;
- if (is_kernel_thread(pid) > 0)
+ if (pid_is_kernel_thread(pid) > 0)
continue;
r = append_process(reply, p, pid, pids);
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Process " PID_FMT " is a manager process, refusing.", pid->pid);
/* Don't even begin to bother with kernel threads */
- r = is_kernel_thread(pid->pid);
+ r = pidref_is_kernel_thread(pid);
if (r == -ESRCH)
return sd_bus_error_setf(error, SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN, "Process with ID " PID_FMT " does not exist.", pid->pid);
if (r < 0)
* them there. */
if (cfrom &&
empty_or_root(pfrom) &&
- is_kernel_thread(pid) > 0)
+ pid_is_kernel_thread(pid) > 0)
continue;
r = cg_attach(cto, pto, pid);
if (r < 0)
return r;
- if (!(flags & OUTPUT_KERNEL_THREADS) && is_kernel_thread(pid) > 0)
+ if (!(flags & OUTPUT_KERNEL_THREADS) && pid_is_kernel_thread(pid) > 0)
continue;
if (!GREEDY_REALLOC(pids, n + 1))
return true;
/* Ignore kernel threads */
- r = is_kernel_thread(pid);
+ r = pid_is_kernel_thread(pid);
if (r != 0)
return true; /* also ignore processes where we can't determine this */
if (r < 0)
continue;
- if (is_kernel_thread(pid))
+ if (pid_is_kernel_thread(pid) != 0)
continue;
cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid, &path);
assert_se(e > 0);
}
- assert_se(is_kernel_thread(pid) == 0 || pid != 1);
+ assert_se(pid_is_kernel_thread(pid) == 0 || pid != 1);
r = get_process_exe(pid, &f);
assert_se(r >= 0 || r == -EACCES);