Skip to content

[bug] Windows daemon launcher fights airc self-host re-exec → crashloop #203

@joelteply

Description

@joelteply

Symptom

After PRs #200, #201, #202 (Windows daemon HKCU Run-key + cwd-scoped + cd-into-cwd launcher) landed, airc daemon install from a project dir crashloops every ~5s. airc daemon status reports "RUNNING (PID xxx)" but the PID is short-lived and the launcher .bat catches the exit + respawns.

Repro on continuum-b69f Windows MINGW64 + canary d4c5e60

  1. cd ~/continuum && airc daemon install
  2. tail daemon.err → continuous "[Tue 04/28/2026 1:05:11.31] airc connect exited. Restarting in 5s." every 5s

Root cause (verified by capturing daemon-style invocation output)

bash -c "exec airc connect" </dev/null from ~/continuum/:

Auto-scoped: #cambriantech (from git org; override with --room or AIRC_NO_AUTO_ROOM=1)
Found #cambriantech on your gh account → joining (39e1de36da82aa3eec2c4d9f834a570d)
✓ Resolved invite from gist.
⚠  Host of #cambriantech is stale (last heartbeat 228s ago) — taking over...
✓ Stale gist removed.
Re-execing into host mode for #cambriantech...

Then airc connect exits. The .bat catches and respawns. Each respawn:

  1. Auto-scopes to #cambriantech (no saved-room because the prior re-exec just rewrote the scope dir)
  2. Finds the gist this same daemon JUST published as host
  3. Tries to take over again or join — exits again

The "Re-execing into host mode" is doing something that makes the parent bash subshell exit (probably forking the host server to background + exiting the foreground), which the .bat interprets as crash + restart.

Why interactive airc connect works fine

When run from an interactive shell, the user sees the same self-heal and host-mode re-exec, but the shell stays in foreground (not backgrounded by start /MIN), so when airc eventually backgrounds itself, the user just keeps the shell open. The .bat's goto loop is what makes this fatal.

Fix surface (not done — needs daylight)

Three options, in order of architectural cleanliness:

  1. Drop the .bat's :loop entirely. airc itself handles backgrounding (via nohup-ish patterns in its host mode). The Run-key just needs to fire it once at logon; airc's own daemon discipline takes over from there. Mirrors how launchd/systemd unit files don't loop — they invoke once and let the service do its thing.

  2. .bat should distinguish "real crash" from "intentional fork-then-exit". airc could write a sentinel file when it forks-and-exits successfully; .bat checks for it and stops looping if present.

  3. airc daemon install should bind to a specific room (the currently-active saved room), not let the daemon-launched airc auto-scope. airc daemon install --room general would write a launcher that runs airc join --room general instead of bare airc connect. That sidesteps the auto-scope + self-heal storm because joining a known room is deterministic.

I lean toward (3) — least invasive, most predictable, matches user mental model ("I daemon-install for THIS room").

Out of scope for this issue

— continuum-b69f, 2026-04-28T01:10Z. Stopping here for the night per Joel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions