← Back to Pull requests

Fix signal handling in `rrun` #1314

Closed
unknown closed this pull request without merging on Nov 10, 2026 19:52 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 10:24 UTC
Author

Stopping an rrun job with Ctrl-C, kill or timeout did not work reliably. Either nothing happened, or rrun died and left its ranks running.

  • Ranks never received SIGINT or SIGTERM. rrun blocked both signals before forking the ranks, and a blocked signal mask survives fork and exec. Forwarded signals, and Ctrl-C from the terminal, stayed pending in every rank.

  • rrun could be killed by the signal instead of forwarding it. The socket coordination server's threads (and the Slurm relay thread) were created before the signals were blocked. A signal could be delivered to one of them, which killed rrun and orphaned the ranks.

  • Only the first signal was handled. Later ones were ignored, so a rank that did not exit kept rrun waiting forever.
  • Changes

  • rrun blocks SIGINT and SIGTERM at the start of main(), before any thread exists. A single signal thread, started right after the arguments are parsed, receives them until rrun exits.

  • While ranks are running, the first SIGINT or SIGTERM is forwarded to all ranks. A signal from the terminal is not forwarded, because the terminal already sends it to its whole foreground process group, which includes the ranks. Ranks still running after --kill-after <s> seconds (default 30, like Slurm) or after a second signal are sent SIGKILL. The message on the first signal says that another Ctrl-C kills them right away.

  • While no rank is running, for example during startup, cleanup or the Slurm hybrid relay, a signal ends rrun as before.

  • Ranks are registered under the same lock as the fork, and only ranks that have not been reaped are signalled, so a signal reaches every rank and a reused pid is never hit.

  • Ranks start with the signal mask rrun was started with.

  • Ranks get PR_SET_PDEATHSIG set to SIGKILL, so they die if rrun itself is killed.

  • The help text says that --kill-after has no effect in Slurm passthrough mode, where rrun execs the application.
  • Tests

    New RrunSignalTest in rrun_tests launches a real rrun (from PATH, or RRUN_BINARY) and checks that:

  • a SIGINT reaches the ranks,

  • a rank ignoring it is killed after --kill-after,

  • a second signal kills at once,

  • ranks die when rrun is killed,

  • a Ctrl-C written to a pseudo-terminal that is rrun's controlling terminal is not forwarded.
  • All five fail against rrun on main. The tests skip when rrun_tests itself runs under rrun, so in CI they run in the final plain ./rrun_tests call of ci/run_rrun_tests.sh. They take about 2.5 s in total locally, most of it the 1 s grace period in one test.

    Diff: 326 lines (+244 / -82) across 4 files Reviewer: wence- Review duration: 7767m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 326 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1314"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42% (MEDIUM) · Higher = larger blast radius
    42%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.6% · Safe to merge
    16.6%