Repository navigation
WIP: fix(suspend): key the no-job-control gate on the job_control variable - #2498
Conversation
… (rubash#2487) GNU's suspend_builtin (builtins/suspend.def:80-126) reads the job_control VARIABLE (jobs.c:223), not the monitor flag: the guards fire only when !force, in source order — job_control == 0 -> sh_nojobs + EXECUTION_FAILURE (suspend.def:103-107), then login_shell -> "cannot suspend a login shell" (suspend.def:109-113) — before killpg (shell_pgrp, SIGSTOP) and EXECUTION_SUCCESS. The variable shadows the flag only at write/startup time: flags.c:257 routes set -m/set +m through set_job_control (jobs.c:5318-5325); shell.c:647 seeds set_job_control (interactive_shell), shell.c:1858 from the -m invocation flag. A fork boundary erases ONLY the variable (jobs.c:5356-5366 without_job_control, called from execute_cmd.c's execute_in_subshell and execute_subshell_builtin_or_function): ( ) regions, pipeline elements, and &-job bodies refuse even under an outer set -m, while $- keeps the m letter. The command-substitution fork keeps the variable (subst.c:7143 command_substitute never touches it). Model the variable as ShellState::job_control (a Cell beside subshell_login_cleared, whose boundary discipline it shares): - writers: the set builtin's monitor writes (recorded into the o_writes replay in execute_set, with short-flag -m writes now recorded by set_with_io_tracked; the two fast set arms sync via a word scan), and Executor::set_shell_option (the startup/API funnel: CLI -m, interactive defaults, and the job-control terminal failure that drops the option again); - boundary resets (set false): the flat ( ) region entry in ast_exec, the scoped subshell entry in compound_exec, the stripped-parens bracket in command_substitution, the pipeline stage bracket in pipeline_exec, and the three cloned pipeline stage executors in pipeline_stages; a fresh process (respawn) starts false in init; - reader: execute_suspend passes the variable and the effective login state (invocation_login && !subshell_login_cleared, execute_cmd.c:1636-1637) into suspend::execute_with_io, whose stop machinery is unchanged (moved verbatim under the guards). Verification (GNU bash 5.3.20 oracle, r46 runner): the frozen master verdict was 38 SAME / 22 DIFF over the 60-case r46 set; with this change 56 SAME / 4 DIFF — all 18 suspend-gate cells flip and no new diffs appear. The remaining diffs are pre-existing and outside the gate: ss27 (foreground-job stop handling in wait_for), ss12 (CONT trap shadowing by suspend_continue), jr09/jr13 (jobs warning faces). New pins tests/issue2487_suspend_job_control_gate.rs: 11/11 under scrubbed fds; tests/issue1474_suspend_timing_regressions still green. Refs #2487
a6cf8a3 to
073354e
Compare
|
[win-acceptance] #2498 PASS — pin Environment: Windows 10 19045 real machine, MSVC Rust debug build of master 9348b8d (contains this merge), GNU oracle = |
Refs #2487
What
suspendin a non-interactive script that ranset -mwas refused withcannot suspend: no job control, because the builtin's gate never saw the monitor state. GNU keys the builtin on the job_control variable (jobs.c:223), not the flag:suspend_builtin(builtins/suspend.def:80-126) checks the variable (then the login-shell guard) only when-fis absent, and the variable is fed byset -m/set +mthrough flags.c:257'sset_job_controlcall — while every fork boundary erases only the variable (jobs.c:5356-5366without_job_control), leaving themletter in the child's$-. Command substitution is the exception: its fork keeps the variable (subst.c:7143).Change
ShellState::job_control: Cell<bool>models the variable, besidesubshell_login_clearedwhose boundary discipline it shares.setbuiltin's monitor writes (o_writes replay inexecute_set; short-flag writes now recorded byset_with_io_tracked; the two fast set arms sync via a word scan) andExecutor::set_shell_option(startup/API funnel — CLI-m, interactive defaults, terminal-failure drop).( )region entry (ast_exec), scoped subshell entry (compound_exec), stripped-parens bracket (command_substitution), pipeline stage bracket (pipeline_exec), the three cloned pipeline stage executors (pipeline_stages); respawned processes start false (init).execute_suspendpasses the variable + effective login state intosuspend::execute_with_io; the stop machinery itself is byte-identical, moved verbatim under the GNU-order guards.Verification
wait_for), ss12 (CONT-trap shadowing bysuspend_continue), jr09/jr13 (jobs warning faces) — classified in the cluster REPORT for separate homing.tests/issue2487_suspend_job_control_gate.rs: 11/11 under scrubbed fds (harness: setsid session + /proc T-state proof + SIGCONT pulse rescue, modeled on tests/issue1474 / runner_r46.py — no pty harness).tests/issue1474_suspend_timing_regressions: still green.cargo check --lib --bins --tests: clean.