process-util: add pidref_is_kernel_thread()

This commit is contained in:
Lennart Poettering
2023-10-18 14:39:33 +02:00
parent a034620f1a
commit fc87713bed
10 changed files with 28 additions and 10 deletions
+18 -1
View File
@@ -389,7 +389,7 @@ int namespace_get_leader(pid_t pid, NamespaceType type, pid_t *ret) {
}
}
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;
@@ -447,6 +447,23 @@ int is_kernel_thread(pid_t pid) {
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;