From 5df5223b4b56b685e024747d360122925108fab8 Mon Sep 17 00:00:00 2001 From: Simon South Date: Wed, 7 Oct 2015 13:53:06 -0400 Subject: [PATCH] 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 --- src/system/kernel/team.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 3fb33aa0fa..83fa90024c 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -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)) {