]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/pager: Properly handle fork error return value
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 3 Mar 2026 17:05:20 +0000 (18:05 +0100)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 3 Mar 2026 17:05:20 +0000 (18:05 +0100)
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 <tobias@stoeckmann.org>
lib/pager.c

index eac0047b11dabd78cce6c1c3f439204eb75e620b..6b94f8f963d5460a4746dbfcc953e0b25fe8565f 100644 (file)
@@ -81,6 +81,7 @@ static int start_command(struct child_process *cmd)
        }
 
        if (cmd->pid < 0) {
+               cmd->pid = 0;
                close_pair(fdin);
                return -1;
        }