Ticket #3417: 0001-kernel-Don-t-send-SIGTTOU-if-calling-thread-is-block.patch

File 0001-kernel-Don-t-send-SIGTTOU-if-calling-thread-is-block.patch, 1.4 KB (added by simonsouth, 9 years ago)

Don't send SIGTTOU if the calling thread is blocking it

  • src/system/kernel/team.cpp

    From 44f722f14bdfced0c9a21711ead6c5be5a34f470 Mon Sep 17 00:00:00 2001
    From: Simon South <ssouth@simonsouth.com>
    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.
    ---
     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 3fb33aa..83fa900 100644
    a b team_set_foreground_process_group(int32 ttyIndex, pid_t processGroupID)  
    29482948    // ignore or block SIGTTOU. Otherwise the group gets a SIGTTOU.
    29492949    if (session->foreground_group != -1
    29502950        && session->foreground_group != team->group_id
    2951         && team->SignalActionFor(SIGTTOU).sa_handler != SIG_IGN) {
     2951        && team->SignalActionFor(SIGTTOU).sa_handler != SIG_IGN
     2952        && (thread->sig_block_mask & SIGNAL_TO_MASK(SIGTTOU)) == 0) {
    29522953        InterruptsSpinLocker signalLocker(team->signal_lock);
    29532954
    29542955        if (!is_team_signal_blocked(team, SIGTTOU)) {