On Tue, Dec 11, 2018 at 11:57:31AM +0200, Lauri Tirkkonen wrote:
> Hi, currently st is reporting a somewhat opaque error number when its
> child process terminates abnormally:
>
> % st sh -c 'exit 1'
> child finished with error '256'
> % st sh -c 'exit 2'
> child finished with error '512'
> % st sh -c 'kill -KILL $$'
> child finished with error '9'
>
> with the diff below it reports properly:
>
> % ./st sh -c 'exit 1'
> child exited with status 1
> % ./st sh -c 'exit 2'
> child exited with status 2
> % ./st sh -c 'kill -KILL $$'
> child terminated due to signal 9
>
> From ed7060de99823938f0e065202ade54ac590011b1 Mon Sep 17 00:00:00 2001
> From: Lauri Tirkkonen <lotheac_AT_iki.fi>
> Date: Tue, 11 Dec 2018 11:43:03 +0200
> Subject: [PATCH] output child WEXITSTATUS/WTERMSIG on abnormal termination
>
> ---
> st.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/st.c b/st.c
> index a51d19c..b8e6077 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -731,8 +731,10 @@ sigchld(int a)
> if (pid != p)
> return;
>
> - if (!WIFEXITED(stat) || WEXITSTATUS(stat))
> - die("child finished with error '%d'\n", stat);
> + if (WIFEXITED(stat) && WEXITSTATUS(stat))
> + die("child exited with status %d\n", WEXITSTATUS(stat));
> + else if (WIFSIGNALED(stat))
> + die("child terminated due to signal %d\n", WTERMSIG(stat));
> exit(0);
> }
>
> --
> 2.19.2
>
> --
> Lauri Tirkkonen | lotheac _AT_ IRCnet
>
Applied, thanks!
--
Kind regards,
Hiltjo
Received on Tue Dec 11 2018 - 18:42:24 CET