Subject: | Don't poll for SIGCHLD if nobody's watching sig(CHLD) |
Currently the SIGCHLD polling loop runs even if nobody has registered a
handler for SIGCHLD. This is wasteful.
The loop should start the first time a session calls sig(CHLD), and it
should end when all sig(CHLD) handlers have been removed.
The loop doesn't need to end right away when the final sig(CHLD) is
removed. It can be allowed to peter out after a queued polling event
has been dispatched.