]> git.ipfire.org Git - thirdparty/systemd.git/commit
process-util: explicitly handle processes lacking parents in get_process_ppid()
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Jul 2021 13:57:51 +0000 (15:57 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 7 Jul 2021 17:41:08 +0000 (18:41 +0100)
commit0c4d1e6d96a549054bfe0597d197f829838917f1
tree03d26661dc8957516a70aa29607767126ea8d80f
parent682047f834112f691716292eb5bd349e51bee3ef
process-util: explicitly handle processes lacking parents in get_process_ppid()

Let's make sure we signal out-of-band via an error message if a process
doesn't have a parent process whose PID we could return. Otherwise we'll
too likely hide errors, as we return an invalid PID 0, which in other
contexts has special meaning (i.e. usually "myself").

Replaces: #20153

This is based on work by @dtardon, but goes a different route, by
ensuring we propagate a proper error in this case.

This modernizes the function in question a bit in other ways, i.e.
renames stuff and makes the return parameter optional.
src/basic/process-util.c
src/coredump/coredump.c
src/test/test-process-util.c