erlang/otp — pull request #165 by proxyles (2013-12-10 15:09:26+00:00)
Title: Propagate exit reason to shell process

In an interactive shell, the shell process has no means to reliably get
the exit reason of the associated user_drv and, therefore, cannot
meaningfully react on errors reported by the user_drv. However, it
occasionally is required to know why an interactive shell session was
terminated.

The patch attached to this e-mail solves the issue by always propagating
the exit reason of the user_drv to the shell process. In summary, the
patch does the following:

* propagate the correct exit reason of the user_drv to the shell
under all circumstances
* always make sure that the shell process terminates when the
user_drv has exited
* give the shell process two seconds time to react on the exit
signal before forcedly killing it

Shell processes using I/O functionality from the io.erl module will be
largely unaffected because io.erl catches exits of the group_leader()
during io_requests and translates them to {error, terminated} error
codes (independent of the exit reason found in the exit signal). Shell
processes implementing the I/O protocol themselfs might experience
unexpected 'EXIT' reasons.

The patch makes sure that shell is forcedly killed as before, it only
gives the shell process a little time to terminate itself before doing
so. It also makes sure that the shell is killed under *ALL*
circumstances, not just while some I/O client is waiting for input