kernel: Don't send SIGTTOU if calling thread is blocking it

POSIX requires SIGTTOU to be sent to a process in a background process
group that tries to change the foreground process group ID associated
with its controlling terminal, unless the process is ignoring SIGTTOU or
the calling thread is blocking it. Previously the code checked the
former condition but not the latter, making it possible for calls to
tcsetpgrp() to get stuck in a loop and never return.

Should fix #3417.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
This commit is contained in:
Simon South 2015-10-07 13:53:06 -04:00 committed by Augustin Cavalier
parent 338fd73327
commit 5df5223b4b

View File

@ -2948,7 +2948,8 @@ team_set_foreground_process_group(int32 ttyIndex, pid_t processGroupID)
// ignore or block SIGTTOU. Otherwise the group gets a SIGTTOU.
if (session->foreground_group != -1
&& session->foreground_group != team->group_id
&& team->SignalActionFor(SIGTTOU).sa_handler != SIG_IGN) {
&& team->SignalActionFor(SIGTTOU).sa_handler != SIG_IGN
&& (thread->sig_block_mask & SIGNAL_TO_MASK(SIGTTOU)) == 0) {
InterruptsSpinLocker signalLocker(team->signal_lock);
if (!is_team_signal_blocked(team, SIGTTOU)) {