screen-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [screen-devel] [PATCH for screen-v4] Fix screen leaving zombie proce


From: Václav Doležal
Subject: Re: [screen-devel] [PATCH for screen-v4] Fix screen leaving zombie processes
Date: Wed, 6 Nov 2019 15:12:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

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 <address@hidden>
> ---
>  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

[Prev in Thread] Current Thread [Next in Thread]