fix(worker): deliver the job-control signal the user asked for (bug-1954)

worker_signal_callback() sent SIGTERM for a KILL request without force and
SIGSTOP for any TSTP request. job_signal_to_deliver() (new job_signal.c) now
delivers the requested signal; only a forced terminate escalates to SIGKILL.
The apiserver's default signal for a plain stop becomes SIGSTOP (it was
TSTP and relied on the worker's substitution), so a plain stop still
suspends jobs that ignore SIGTSTP.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-10-10 09:07:38 +00:00
parent e00526f9f5
commit 148557a5d5
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
9 changed files with 99 additions and 11 deletions

View file

@ -284,7 +284,9 @@ func jobCtrlParams(action int, content string) (jobCtrlArgs, error) {
func defaultActionSignal(action int) int {
switch action {
case models.JOB_STOP:
return models.JobSignalMapTable["TSTP"] // 20
// bug-1954: the worker delivers the requested signal, so a plain
// stop asks for the uncatchable SIGSTOP
return models.JobSignalMapTable["STOP"] // 19
case models.JOB_RESUME:
return models.JobSignalMapTable["CONT"] // 18
}

View file

@ -55,7 +55,7 @@ func TestJobCtrlParams_DefaultSignalPerAction(t *testing.T) {
want int
}{
{models.JOB_KILL, 15},
{models.JOB_STOP, 20},
{models.JOB_STOP, 19}, // bug-1954: SIGSTOP
{models.JOB_RESUME, 18},
}
for _, tc := range cases {
@ -116,3 +116,18 @@ func TestJobCtrlParams_CheckpointCarriesKillAndMethod(t *testing.T) {
got.CkptKill, got.Method)
}
}
// bug-1954: the worker now delivers the requested signal as is, so a plain
// stop must ask for SIGSTOP (a job may ignore SIGTSTP).
func TestJobCtrlParams_PlainStopSendsSigstop(t *testing.T) {
args, err := jobCtrlParams(models.JOB_STOP, "")
if err != nil {
t.Fatalf("jobCtrlParams: %v", err)
}
if args.Signo != models.JobSignalMapTable["STOP"] {
t.Errorf("plain stop: signo %d, want SIGSTOP (%d)", args.Signo, models.JobSignalMapTable["STOP"])
}
if models.DefaultActionSignal["stop"] != "STOP" {
t.Errorf("DefaultActionSignal[stop] = %q, want STOP", models.DefaultActionSignal["stop"])
}
}

View file

@ -127,7 +127,7 @@ var JobKillSignalControlMap = map[int][]int{
var DefaultActionSignal = map[string]string{
"kill": "TERM",
"stop": "TSTP",
"stop": "STOP", // bug-1954: the worker delivers exactly this signal
"resume": "CONT",
}