Skip to content

fix(teardown): kill env-var-tagged orphans (AIRC_HOME) - #326

Merged
joelteply merged 1 commit into
canaryfrom
fix-teardown-env-var-orphans
Apr 29, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix-teardown-env-var-orphans

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

After airc.pid-driven kill, also walk ps eww -o pid,command and kill any process whose env has AIRC_HOME=<scope>. Catches detached subshells that reparented to init and dropped out of airc.pid's tracking. Pairs with #325 (subshells self-exit on parent death).

Production failure mode: detached subshells (heartbeat / reminder /
flush loops, bearer pipeline subshell) survived their parent's death
and got reparented to init. airc.pid stopped tracking them after the
reparent, so teardown's pidfile-driven kill missed them entirely.
Result: 'airc connect' refused via #292 stomp guard ("this scope's
monitor is already running") because the new spawn saw orphan PIDs
that teardown hadn't actually killed.

Fix: after the airc.pid pass, also walk every process whose
environment has AIRC_HOME=<this scope> and kill it. ps eww -o
pid,command exposes env on macOS + Linux; awk-match scope to env
variable. Catches orphan reparents regardless of how they got
detached. Self-exclusion guards against teardown killing itself
mid-run.

Pairs with #325 (orphan loops self-exit on parent death) — this
catches the orphans that already exist; the parent-PID check
prevents NEW orphans from accumulating. Together close the
'monitor frozen, only Reminder firing' symptom Joel kept seeing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@joelteply
joelteply merged commit d781245 into canary Apr 29, 2026
6 checks passed
@joelteply
joelteply deleted the fix-teardown-env-var-orphans branch April 29, 2026 17:10
joelteply added a commit that referenced this pull request Apr 29, 2026
fix(teardown): pgrep -f scope-path orphan sweep + 3 new TDD scenarios

cmd_teardown #326 follow-up: macOS BSD ps doesn't expose env vars
for processes started by other shells, so the original ps eww +
AIRC_HOME match couldn't see anything. Switched to pgrep -f
"$AIRC_WRITE_DIR" which catches every process whose argv contains
the scope path — including all airc python children (handshake,
monitor_formatter, bearer_cli) which all pass scope paths on argv.
The bash parent doesn't have scope on argv but its python children
dying cascades it down via SIGCHLD/SIGPIPE.

Three new test/integration_smoke.sh scenarios for the loop-
liveness + teardown layer Joel asked about:

  orphan_loops_self_reap: kill bash parent, assert subshell loops
    self-reap within 9s. Verifies #325. Currently 2/3 expected
    (reminder + flush exit; the foreground monitor() loop dies
    when its parent dies, not via subshell self-reap).

  teardown_kills_env_tagged_orphans: corrupts airc.pid to simulate
    broken-tracking state, then asserts airc teardown's pgrep -f
    sweep still kills every scope-path-tagged process. 15s timeout
    so a hung teardown can't wedge the test.

  my_scope_in_mesh: 'remember you need to be part of it'. Spawns
    a fresh test peer + asserts the user's primary running scope
    (~/Development/ideem/authenticator/.airc) receives the test
    peer's broadcast in its local log. Catches issues that only
    manifest with multiple already-running peers.

orphan_loops_self_reap passes locally (2 of 3 bash subshells exit
within 9s post-kill). teardown_kills_env_tagged_orphans + my_scope_in_mesh
require a clean shell — current session has too many zombie test
processes from earlier runs.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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