Re: [hackers] [st][PATCH] Inhibited st from reporting I/O error when process dies

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 13 May 2018 22:33:46 +0200

On Sun, May 13, 2018 at 06:57:23PM +0200, Philip K wrote:
> ---
> st.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/st.c b/st.c
> index 0628707..d5cfd74 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -824,10 +824,15 @@ ttyread(void)
> static int buflen = 0;
> int written;
> int ret;
> + pid_t ret_pid;
>
> /* append read bytes to unprocessed bytes */
> - if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
> - die("couldn't read from shell: %s\n", strerror(errno));
> + if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) {
> + ret_pid = waitpid(pid, NULL, WNOHANG);
> + if (ret_pid == pid) /* child is dead */
> + exit(EXIT_SUCCESS);
> + else die("couldn't read from shell: %s\n", strerror(errno));
> + }
> buflen += ret;
>
> written = twrite(buf, buflen, 0);
> --
> 2.17.0
>
>

Can you give more explanation what it fixes and how to reproduce it?

Thanks,

-- 
Kind regards,
Hiltjo
Received on Sun May 13 2018 - 22:33:46 CEST

This archive was generated by hypermail 2.3.0 : Sun May 13 2018 - 22:36:23 CEST