fix(queue): cancel ends every process of the job on Linux, its game too #2155
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2155
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/queue-cancel-ends-game"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On Linux,
dev.py queue cancel <job>said "stopped " but left the job's game running. A cancelled game run(
dev.py ab, or anylongshot_bridge.start_session(..., wrapper=[... dev.py queue run ...])) kept its game and thegame's
--crash-watchprocess alive, holding the GPU and several GB of memory, so the next timed run waited behind agame nobody owned.
queue statusstill listed it asgame: longshot pid N under job Mfor a job that was gone.Why:
cancelsent SIGTERM to the runner only; the runner'sfinallyterminated its direct child only. Under a gamerun, that child is the bridge's supervisor (
scripts/longshot_bridge.py,supervise()), which has no SIGTERM handler,so it died at once without stopping the game it started. The game and its crash watcher were orphaned, out of the
runner's process tree, with nothing stopping their systemd scope. Windows was fine: its job object ends the tree.
What changes (
scripts/devtools/jobqueue.py,procs.running()inscripts/devtools/procs.py), Linux only:job_procs(t): a job's processes, as {pid: start time}: its command's tree, plus every process whose environmentcarries this job's
LONGSHOT_JOB(the runner's pid) andLONGSHOT_JOB_NAME, however it detached.end_job(): SIGTERM to all of them and to the job's systemd scope, rescanning for late children (the crash watcher),then SIGKILL to what is left after 10 s. A pid is signalled only while its start time matches, never a reused one.
end_jobinstead ofchild.terminate().cancelsnapshotsjob_procsbefore it stops the runner and then runsend_jobitself, so a runner of an olderqueue version is covered too. It refuses a ticket from another pid namespace, whose pids name other processes here.
longshot_bridge.pyare unchanged.Read first:
job_procs,end_jobandcancelinscripts/devtools/jobqueue.py.Testing
Tested: CachyOS Linux. The bug as seen on this PC on main: a
dev.py queue run --mode timinggame run startedthrough
longshot_bridge.start_session, thendev.py queue cancelon it: the runner ended, and the game and its crashwatcher kept running until killed by hand. New game-free checks in
tests/test_job_queue.py(PosixTree, skipped onWindows): a real queue in a temporary folder, the command standing in for the supervisor, starting a grandchild "game".
They have not been run on this PC (its owner runs no test suites here); CI runs them.
test_cancel_ends_the_game_its_supervisor_started,test_cancel_ends_a_game_in_a_session_of_its_own(fail on main:the grandchild is still running 15 s after the cancel)
test_cancel_leaves_another_jobs_process(another job's process survives)test_a_command_that_ends_leaves_what_it_started(passes on main too: behaviour that must not change)Still to test:
dev.py queue cancelit, expectingqueue statusto show nogame left under that job and the line "stopped NAME (pid N) and K processes of its job" (by hand)
PosixTreechecks pass, and the three cancel ones fail on main (CI)Measurements
Nothing to measure in the game: a developer tool's cancel path; no game file changes. Its own cost: a cancel can now
take up to 10 s while the game shuts down, scanning
/procevery 0.2 s meanwhile.Risks
runner's pid. A process that drops
LONGSHOT_JOBis still caught through the tree snapshot or the systemd scope.Checklist
Ready for review
main; the title is a Conventional Commit.game run on this PC is still to do.)
mise run testpasses (any failure that also fails onmainis named). (CI runs it; not run on this PC.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Possibly related, for context:
WIP: fix(queue): cancel ends every process of the job on Linux, its game tooto fix(queue): cancel ends every process of the job on Linux, its game too