vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 81d473f519f45ec44bd306687189a918473e302b
parent 79784d5bb856121831eda552994ae02e541421ca
Author: Randy Palamar <palamar@ualberta.ca>
Date:   Tue, 10 Oct 2023 20:55:56 -0600

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.

Diffstat:
Mvis.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vis.c b/vis.c @@ -1960,7 +1960,10 @@ err: 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) {