Leftover processes end before a workspace goes, and only those

Before Obeya deletes a card's workspace, it runs the repository's stop command and then ends whatever still runs from the folder. Pull request #67 brought that in (its own demo, recorded on Windows: here). The tables show the same cases run on macOS against the pull request as it came and with the fixes on top. ✓ is what should happen.

Which stop commands run

A stop command whose script the card's older branch does not have yet is skipped: nothing of it can run there. Every other stop command runs. Shown with harmless stand-ins that read or name the same things.

Stop command, in a workspace without those filesPull requestWith the fixes
node .obeya/app.mjs stop
the script is not on this branch yet
skippedskipped
echo stopped $(cat .run/app.pid 2>/dev/null)
reads a file of process IDs, like kill $(cat .run/app.pid)
skippedruns
echo stopped localhost:3000/stop
names an address, like curl localhost:3000/stop
skippedruns
./scripts/stop.sh
the script is not on this branch yet
skippedskipped

What ends when the workspace goes

A workspace with an app running in it, a helper the app started that works elsewhere, a terminal someone opened in it, and someone else's viewer of one of its files. The app and its helper should end. The terminal and the viewer belong to someone, not to the app, and should keep running.

The workspace by the path Obeya knows it by: /var/folders/…, which macOS reports as /private/var/folders/…

Pull requestWith the fixes
The app, started in the workspacerunningended
A helper the app started, working in /tmprunningended
A terminal opened in the workspacerunningrunning
A viewer of one of its files (tail -f …/notes.txt), started elsewhererunningrunning
Time to find and end them424 ms525 ms

The workspace by its real path

Pull requestWith the fixes
The app, started in the workspaceendedended
A helper the app started, working in /tmprunningended
A terminal opened in the workspaceendedrunning
A viewer of one of its files (tail -f …/notes.txt), started elsewhereendedrunning
Time to find and end them3383 ms345 ms

Also changed

A clone that leaves the pool is checked for files that would be lost after its app has ended, not before, so a snapshot the app saves as it ends keeps the clone on disk. On Windows the process listing has a time limit of 30 seconds, and processes that started before the workspace existed are read too, as long as time allows. The Windows part was only typechecked here, not run.