lib/pty-session: Don't ignore SIGHUP. #2836
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The blamed commit converted script to use the generic pty code that was added by commit 6954895 ("lib/pty-session: add generic PTY container code").
Commit ec10634 says the new pty stuff is based on script. However, there is difference in signal handling.
Before the commit, only the signals that the script was interested in were blocked and handled by signalfd.
After the commit, all signals are blocked and only the interested signals are handled.
This causes regression in the following scenario:
script
via /etc/profile.d for ssh sessionsudo -i
After 3., the process tree will be like this.
The notable thing here is that script is in the parent's process group (637997).
Thus, the parent bash will send SIGHUP to script, when the timeout occurs at 4.
However, this is not handled, so the script is reaped but remains forever.
To avoid such a situation, we need to handle SIGHUP in script.
With this patch, script will receive SIGHUP from the parrent and kill its child processes.
Fixes: ec10634 ("script: use lib/pty-session")
Reported-by: Ayame Suzuki ayameszk@amazon.co.jp