From: Tobias Stoeckmann Date: Tue, 3 Mar 2026 17:05:20 +0000 (+0100) Subject: lib/pager: Properly handle fork error return value X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51c4a282f49cc30e00fc9e582d0b3967384d07cb;p=thirdparty%2Futil-linux.git lib/pager: Properly handle fork error return value Most of the code checks for pager_process.pid != 0 to see if a pager is running. If fork fails and returns -1, pager_process.pid is not 0, too. This in turn leads to an issue if waitpid is eventually called with -1 as pid, which would wait for all children. Since there are no children, the wait_for_pager function calls err with an EXIT_FAILURE value. Properly handle a potential fork error. Signed-off-by: Tobias Stoeckmann --- diff --git a/lib/pager.c b/lib/pager.c index eac0047b1..6b94f8f96 100644 --- a/lib/pager.c +++ b/lib/pager.c @@ -81,6 +81,7 @@ static int start_command(struct child_process *cmd) } if (cmd->pid < 0) { + cmd->pid = 0; close_pair(fdin); return -1; }