chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:58:54 +0000 (07:58 +0200)
commit0bdf2a3d4f8c159a36b9cf62ad69ee5eddc8e8b4
treeffe2082c8b26837b09fd609dec740e503488604f
parent801b1cd08dd22c45f14662b8cc7a16e36fbba364
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