[Bug 228728] sh does not reap killed background processes until terminal activity, creating zombies

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Jun 3 20:13:26 UTC 2018


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 at FreeBSD.org
          Reporter: mqudsi at 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.


More information about the freebsd-bugs mailing list