From: Tobias Stoeckmann Date: Mon, 19 Jan 2026 18:09:07 +0000 (+0100) Subject: lib/pager: Remove struct field preexec_cb X-Git-Tag: v2.43-devel~136^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c4aa03eae60b0912e13fee1cc7f2ec6acbd263c5;p=thirdparty%2Futil-linux.git lib/pager: Remove struct field preexec_cb The struct field preexec_cb is always set to pager_preexec. Simplify the code by calling this function directly. Removes function pointer handling. Signed-off-by: Tobias Stoeckmann --- diff --git a/lib/pager.c b/lib/pager.c index cbd08964e..b753c5f6d 100644 --- a/lib/pager.c +++ b/lib/pager.c @@ -42,7 +42,6 @@ struct child_process { struct sigaction orig_sigpipe; bool no_stdin; - void (*preexec_cb)(void); }; static struct child_process pager_process; @@ -52,6 +51,24 @@ static inline void close_pair(int fd[2]) close(fd[1]); } +static void pager_preexec(void) +{ + /* + * Work around bug in "less" by not starting it until we + * have real input + */ + fd_set in, ex; + + FD_ZERO(&in); + FD_SET(STDIN_FILENO, &in); + ex = in; + + select(STDIN_FILENO + 1, &in, NULL, &ex, NULL); + + if (setenv("LESS", "FRSX", 0) != 0) + warn(_("failed to set the %s environment variable"), "LESS"); +} + static int start_command(struct child_process *cmd) { int need_in; @@ -79,7 +96,7 @@ static int start_command(struct child_process *cmd) close(cmd->in); } - cmd->preexec_cb(); + pager_preexec(); execvp(cmd->argv[0], (char *const*) cmd->argv); errexec(cmd->argv[0]); } @@ -134,24 +151,6 @@ static int finish_command(struct child_process *cmd) return wait_or_whine(cmd->pid); } -static void pager_preexec(void) -{ - /* - * Work around bug in "less" by not starting it until we - * have real input - */ - fd_set in, ex; - - FD_ZERO(&in); - FD_SET(STDIN_FILENO, &in); - ex = in; - - select(STDIN_FILENO + 1, &in, NULL, &ex, NULL); - - if (setenv("LESS", "FRSX", 0) != 0) - warn(_("failed to set the %s environment variable"), "LESS"); -} - static void wait_for_pager(void) { if (pager_process.pid == 0) @@ -235,7 +234,6 @@ static void __setup_pager(void) pager_argv[2] = pager; pager_process.argv = pager_argv; pager_process.in = -1; - pager_process.preexec_cb = pager_preexec; if (start_command(&pager_process)) return;