Skip to content

[linux] Blocked rubash is unkillable by SIGTERM: signal_hook installs with SA_RESTART and pending signals dispatch only at command boundaries #226

Closed

Description

@caomengxuan666

Observed on the Linux build (wt4/linuxrun), while investigating the redir/trap suite hangs.

Repro

# any hang becomes unkillable: run a suite that blocks, then try timeout without -k
cd target/issue-suites/results/bash-tests-rw
timeout 20 <rubash-linux> ./trap.tests    # blocks; TERM at 20s does nothing; timeout waits forever

ps after the 20 s window: timeout 20 ... rubash ./trap.tests still alive, rubash still alive. Only SIGKILL works (harness timeout -k 5 40 ends as rc 137 = 128+SIGKILL).

Expected (GNU 5.3.0): SIGTERM terminates/interrupts a blocked bash immediately (sig.c:102 initialize_terminating_signals; sig.c:133 termsig_handler). GNU installs signal handlers with SIG interruption of blocking syscalls (no SA_RESTART for terminating signals), and wait/read loops check for pending trapped signals.

Actual (rubash Linux): src/builtins/kill.rs kernel_signals backend (signal_hook::iterator::Signals for INT/TERM/HUP/QUIT/USR1/USR2) catches SIGTERM into a queue that is drained only at command boundaries; because signal_hook registers handlers with SA_RESTART, the blocked read/wait syscall restarts transparently and the queued TERM is never dispatched while blocked. Net effect: any blocked state = immune to SIGTERM.

Fix direction: install terminating-signal handlers without SA_RESTART (or make the drain point also run from the blocking read/wait loops on EINTR), citing sig.c:102/133. Cross-checked with docs/cross-platform-gap-ledger.md E10 (interactive Ctrl-C) - same family, but the unkillable-script consequence is new evidence from the Linux corpus run.

Artifacts: target/wslrun/results/linux-ledger2.log (trap 30 rc 137, redir 58 rc 137); live ps capture in lane notes (docs/LINUX-RUN-STATUS.md).

Activity

  1. added
    bug
    platform:linux
    on Sep 27, 2026
  2. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(commit b2e41b4e,lane wt4/linuxfix;GNU 引用与验证见提交信息:Linux 真机 WSL 双壳验证、24 套件平价 17→19)。感谢报告!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugplatform:linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions