]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tools subcmd: Robust fallback and existence checks for process reaping
authorIan Rogers <irogers@google.com>
Tue, 2 Jun 2026 17:41:18 +0000 (10:41 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jun 2026 14:36:51 +0000 (11:36 -0300)
commitc7dacfb87beed63ffe360c73c2a284d9e334f135
tree8ed184788cca40f2b7dea71bedc1f1f6c7f57fee
parent8ae26f6ae7013f0ba753feed723eb0613796cb67
tools subcmd: Robust fallback and existence checks for process reaping

Update check_if_command_finished() and wait_or_whine() to handle invalid
PIDs gracefully (<= 0) by setting cmd->finished = 1 and returning early.
This avoids executing waitpid(-1, ...) or waitpid(0, ...) downstream,
which can block or reap parallel tests' exit status causing state
corruption.

Introduce a fallback mechanism in check_if_command_finished() using
waitpid(..., WNOHANG) when /proc/<pid>/status is inaccessible (e.g. due
to EMFILE/ENFILE) to safely check and reap finished children.

Assisted-by: Gemini-CLI:Google Gemini 3
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/subcmd/run-command.c