Skip to content

Stop SFTP subprocess groups when a backup is cancelled - #36

Merged
mikecerisano merged 2 commits into
mainfrom
fix/sftp-process-cancel-20261017
Oct 17, 2026
Merged

mikecerisano merged 2 commits into
mainfrom
fix/sftp-process-cancel-20261017

Conversation

@mikecerisano

@mikecerisano mikecerisano commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

A cancelled SFTP backup could leave an SSH ProxyCommand descendant holding stdout and stderr open after the direct ssh process exited. The old runner signalled only the direct process, then waited indefinitely for both pipes to drain. The transfer could remain stuck instead of settling as cancelled.

The Mac-only runner now launches each command in its own process group with posix_spawn, preserving fixed arguments, environment, and standard streams. Cancellation sends TERM to that group and escalates to KILL after two seconds. It keeps the leader PID reserved until the pipes close and the escalation is disarmed, then reaps it. Cancellation cannot be reported as success. The same pass prevents an early child exit from sending SIGPIPE to BitMatch while it writes SFTP batch input; a short write cannot yield a successful command result.

Local validation on the rebased head:

  • Focused SFTPRemoteBackupProcessTests: 8 passed, 0 failed, including a direct child that exits before cancellation while a TERM-ignoring descendant holds both pipes, a child that closes output before exiting, and an early-closed stdin pipe.
  • Full serialized Mac app suite: TEST SUCCEEDED, xcresult overall 1,164 passed, 13 skipped, 0 failed. Its device/configuration view counts 1,210 passed because Xcode counts some parameterized cases differently.
  • git diff --check: clean.

The combined follow-up SFTP branch also passed a real disposable localhost sshd upload/readback test (1/1) using temporary keys, an agent, pinned known-hosts and a remote root. That exercises this runner with an actual SSH connection; the cancellation edge cases are covered by the focused subprocess tests. It does not establish compatibility with a shell-less, SFTP-only server or with an external server. SFTP is Mac-only. These are local gates; no manual GitHub CI rerun was used.

@mikecerisano mikecerisano changed the title Stop SFTP child processes when a backup is cancelled Stop SFTP subprocess groups when a backup is cancelled Oct 17, 2026
@mikecerisano
mikecerisano force-pushed the fix/sftp-process-cancel-20261017 branch from 35f4dc7 to 1abf0a0 Compare October 17, 2026 15:04
@mikecerisano
mikecerisano marked this pull request as ready for review October 17, 2026 15:04
@mikecerisano
mikecerisano merged commit ee84604 into main Oct 17, 2026
4 of 8 checks passed
@mikecerisano
mikecerisano deleted the fix/sftp-process-cancel-20261017 branch October 17, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant