Skip to content

Commit

Permalink
vis_pipe: correctly return non-zero exit status
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rnpnr committed Oct 11, 2023
1 parent d7cd42e commit aa18162
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit aa18162

Please sign in to comment.