Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 03 Jun 2018 20:13:24 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 228728] sh does not reap killed background processes until terminal activity, creating zombies
Message-ID:  <bug-228728-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=228728

            Bug ID: 228728
           Summary: sh does not reap killed background processes until
                    terminal activity, creating zombies
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: mqudsi@neosmart.net

The default `sh` shell does not reap backgrounded processes if sitting idle,
and killed backgrounded processes are not reaped until a new command is
executed or enter is pressed at the tty.

For example, 

```
$ cat
<CTRL-Z>
[1] + Suspended                     cat
$ 
```

Now in another terminal or in an SSH session:

```
$ killall -9 cat
```

The PID associated with cat is turned into a zombie as the shell does not reap
the killed instance. The only way to trigger reaping would be to attach to the
tty session where the process was initially backgrounded and hit <ENTER>:


```
$ cat
# resuming from first segment above 
$ <ENTER>
[1] Killed                          cat
$ 
```


Solution: `waitpid(2)` should be used to asynchronously detect the exit of
backgrounded child processes.

-- 
You are receiving this mail because:
You are the assignee for the bug.


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-228728-227>