+++ This bug was initially created as a clone of Bug #2176707 +++ We backported a buggy commit (5fb7fc96350575c9adb1316833e48ca11553be49) in bug 2065588 that landed in glibc-2.28-211. Specifically, in the following scenario with two threads in the same process: 1. Thread A calls system but hasn't returned yet 2. Thread B calls another system but returns I observed that SIGCHLD would be blocked forever in thread B after its system() returns, even after the system() in thread A returns (though I believe it should unblock it after system() in thread B returns). This was not the case before this patch. I've attached a simple C reproduction program to this bug. It doesn't print anything on previously but prints "SIGCHLD is erroneously blocked" with glibc-2.28-211. I filed this bug upstream (sourceware bug 30163) and this is fixed in upstream in 436a604b7dc741fc76b5a6704c6cd8bb178518e7. Can we backport the fix as well?
Upstream fix: commit 436a604b7dc741fc76b5a6704c6cd8bb178518e7 Author: Adam Yi <ayi> Date: Tue Mar 7 07:30:02 2023 -0500 posix: Fix system blocks SIGCHLD erroneously [BZ #30163] Fix bug that SIGCHLD is erroneously blocked forever in the following scenario: 1. Thread A calls system but hasn't returned yet 2. Thread B calls another system but returns SIGCHLD would be blocked forever in thread B after its system() returns, even after the system() in thread A returns. Although POSIX does not require, glibc system implementation aims to be thread and cancellation safe. This bug was introduced in 5fb7fc96350575c9adb1316833e48ca11553be49 when we moved reverting signal mask to happen when the last concurrently running system returns, despite that signal mask is per thread. This commit reverts this logic and adds a test. Signed-off-by: Adam Yi <ayi> Reviewed-by: Adhemerval Zanella <adhemerval.zanella>
setting r_d_t