From aa18162e2d62d1a4a618ee65289ba8b1cdeaf29a Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Tue, 10 Oct 2023 20:55:56 -0600 Subject: [PATCH] vis_pipe: correctly return non-zero exit status according to POSIX wait(3p) the return status needs to be checked and the macro WEXITSTATUS(stat_val) should be used to get the actual return value on a normal exit. POSIX doesn't specify the value of stat_val on abnormal exit and thus vis_pipe() should just return -1 as it does for other errors closes #1130: vis:pipe returns wrong exit status (when non-zero) Thanks @pippi1otta for the report and suggestion. --- vis.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vis.c b/vis.c index 004295b0b..2a4d6ae55 100644 --- a/vis.c +++ b/vis.c @@ -1960,7 +1960,10 @@ int vis_pipe(Vis *vis, File *file, Filerange *range, const char *argv[], vis->interrupted = false; vis->ui->terminal_restore(vis->ui); - return status; + if (WIFEXITED(status)) + return WEXITSTATUS(status); + + return -1; } static ssize_t read_buffer(void *context, char *data, size_t len) {