This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 619526d50411d36bc904c6ebcf6bb7c7f430ddf7 Author: Marco Casaroli <[email protected]> AuthorDate: Tue Nov 3 22:53:39 2026 +0100 sched/signal: Cancel the other threads at once in a default action. The default action of SIGTERM, SIGINT, SIGSEGV and the other signals that end a process calls group_kill_children(). When CONFIG_GROUP_KILL_CHILDREN_TIMEOUT_MS is not 0 (the default is -1), group_kill_children() first sends SIGTERM to each other thread and waits until these threads exit. A thread that blocks SIGTERM does not exit, so the process did not end: with -1 the wait has no limit, and with a timeout the process ended only after the timeout. POSIX says that the default action ends the whole process. Set TCB_FLAG_FORCED_CANCEL on the thread that does the default action, as the exception handlers do before they call _exit(). group_kill_children() then cancels the other threads at once. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- sched/Kconfig | 2 ++ sched/signal/sig_default.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sched/Kconfig b/sched/Kconfig index 615cf065636..b651b54f2d7 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -2100,6 +2100,8 @@ config GROUP_KILL_CHILDREN_TIMEOUT_MS < 0 means wait until all the child thread exit > 0 means wait timeout = 0 means don't do kill signal + The default action of a signal (abnormal termination) does not + send the signal: it cancels the other threads at once. config PID_INITIAL_COUNT int "Initial length of pid table" diff --git a/sched/signal/sig_default.c b/sched/signal/sig_default.c index 5922319851a..8a2747eabe6 100644 --- a/sched/signal/sig_default.c +++ b/sched/signal/sig_default.c @@ -222,9 +222,11 @@ static void nxsig_abnormal_termination(int signo) #ifdef HAVE_GROUP_MEMBERS /* Kill all of the children of the task. This will not kill the currently * running task/pthread (this_task). It will kill the main thread of the - * task group if this_task is a pthread. + * task group if this_task is a pthread. Cancel them at once, as for a + * fatal exception: a thread can block or catch SIGTERM. */ + rtcb->flags |= TCB_FLAG_FORCED_CANCEL; group_kill_children(rtcb); #endif
