I think this is bad solution. If some process deliberately closes stdout and
stderr, screen will block until that process exits.

I am wondering why the zombies show up at all. They were reaped correctly on
my test process (code below). I guess there is some race with SIGCHLD handler.

Regards,
Václav Doležal

---
#include <unistd.h>
#include <signal.h>

int main()
{
        signal(SIGHUP, SIG_IGN);

        close(0);
        close(1);
        close(2);

        sleep(30);

        return 0;
}
---

Dne 02. 11. 19 v 22:59 Amadeusz Sławiński napsal(a):
> When window dies we should wait for child process to die, otherwise
> there is no one to reap it.
> 
> So emove WNOHANG in waitpid(), which may cause screen to not wait for
> child to die and kill window, leaving zombie process.
> 
> Bug: 25089
> 
> Signed-off-by: Amadeusz Sławiński <am...@asmblr.net>
> ---
>  src/screen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/screen.c b/src/screen.c
> index c50952b6..f8e7e11a 100644
> --- a/src/screen.c
> +++ b/src/screen.c
> @@ -1492,7 +1492,7 @@ int wstat_valid;
>    if (!wstat_valid && p->w_pid > 0) {
>        /* EOF on file descriptor. The process is probably also dead.
>         * try a waitpid */
> -    if (waitpid(p->w_pid, &wstat, WNOHANG | WUNTRACED) == p->w_pid) {
> +    if (waitpid(p->w_pid, &wstat, WUNTRACED) == p->w_pid) {
>        p->w_pid = 0;
>        wstat_valid = 1;
>      }
> 


Reply via email to