process-util: be more careful in is_kernel_thread()
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Feb 2018 14:59:55 +0000 (15:59 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 12 Feb 2018 10:34:00 +0000 (11:34 +0100)
commit36b5119a0c469df85be0b1807ee866aba5e33287
tree3b31cfda7fdec49cca938700ee525f22799c7881
parent004c7f169e8b9b1a6201bcd1dc611ff6efe501f9
process-util: be more careful in is_kernel_thread()

This reworks is_kernel_thread() a bit. Instead of checking whether
/proc/$pid/cmdline is entirely empty we now parse the 'flags' field from
/proc/$pid/stat and check the PF_KTHREAD flag, which directly encodes
whether something is a kernel thread.

Why all this? With current kernels userspace processes can set their
command line to empty too (through PR_SET_MM_ARG_START and friends), and
could potentially confuse us. Hence, let's use a more reliable way to
detect kernels like this.
src/basic/missing.h
src/basic/process-util.c