You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
attach restarts a dead session without consent when stdin is not a TTY (EOF defaults to yes) #214
@myobie, Compounding Manager reports a pre-existing behavior from a live smoke test of #209 (evidence: schickling/dotfiles#8391 comment 6620845281).
Observed:pty attach <name> on a session that pty classifies as dead (here: a record whose daemonStartToken does not match the live PID) prints Restart? [Y/n]. When stdin is not a terminal or is at EOF, the answer defaults to yes. attach then removes the old record, spawns a new daemon that reruns the stored command, and attaches to it. --force behaves the same. Reproduced with 74e4dbb and with rust.5 (65bf24d), so #209 did not introduce it.
Why it matters: agents call attach non-interactively. A non-interactive caller cannot consent, yet the stored command runs again. For mutating commands this repeats side effects (same concern as #204).
Question: should a prompt with no answer (no TTY or EOF) default to "no" and exit non-zero, so that a restart needs an explicit y or a flag such as attach -r?
Safety part passed: the unrelated process that reused the PID was never attached to or signalled.
I measured this at main ddfcf093, with no terminal.
What the code does today
attach on a dead session prints the last lines and asks Restart? [Y/n] (attach.rs#L231).
ask.rs reads one line with no terminal check, and only a lone n declines. EOF reads as an empty answer, so </dev/null restarts (ask.rs#L13-L31).
--force only allows attaching from inside another session. It never answered the prompt, so it restarts the same way.
-r restarts without asking. --no-restart refuses with exit 1 before the stored command is considered, and it is the safe flag for callers today.
A correction.ask.rs says a closed stdin proceeds "exactly like Node", and I repeated that on #204. It's wrong for EOF. I built the pinned Node reference (f005432a) and ran it with no terminal, on Node 22 and on 24. At EOF its readline question never resolves, and the process exits 0 without restarting. It does restart on any piped line but n, an empty line included.
An unanswered prompt declines. Off a terminal, only y or yes restarts, and EOF never does.
With no answer, attach exits 1 and keeps the exited record. It says Answer y, or pass -r to restart it without asking.
These are unchanged: a terminal's Enter restarts, n exits 0, -r restarts without asking, and --force answers nothing.
Decision 0020 records the departure from Node. A script that relied on a non-interactive restart must pass -r.
The other prompt with this shape is pty restart's Kill and restart? [Y/n]. With </dev/null it stops a running session and starts it again. Node exits 0 and leaves the session running. #215 leaves it unchanged; it's listed there for a separate fix.
Activity
myobie commentedon Nov 4, 2026
I measured this at main
ddfcf093, with no terminal.What the code does today
attachon a dead session prints the last lines and asksRestart? [Y/n](attach.rs#L231).ask.rsreads one line with no terminal check, and only a lonendeclines. EOF reads as an empty answer, so</dev/nullrestarts (ask.rs#L13-L31).--forceonly allows attaching from inside another session. It never answered the prompt, so it restarts the same way.-rrestarts without asking.--no-restartrefuses with exit 1 before the stored command is considered, and it is the safe flag for callers today.A correction.
ask.rssays a closed stdin proceeds "exactly like Node", and I repeated that on #204. It's wrong for EOF. I built the pinned Node reference (f005432a) and ran it with no terminal, on Node 22 and on 24. At EOF itsreadlinequestion never resolves, and the process exits 0 without restarting. It does restart on any piped line butn, an empty line included.ddfcf093</dev/nullyoryesn-r,</dev/null--force,</dev/nullThe change, decided and in #215.
yoryesrestarts, and EOF never does.attachexits 1 and keeps the exited record. It saysAnswer y, or pass -r to restart it without asking.nexits 0,-rrestarts without asking, and--forceanswers nothing.Decision 0020 records the departure from Node. A script that relied on a non-interactive restart must pass
-r.The other prompt with this shape is
pty restart'sKill and restart? [Y/n]. With</dev/nullit stops a running session and starts it again. Node exits 0 and leaves the session running. #215 leaves it unchanged; it's listed there for a separate fix.Merge pull request #215 from compoundingtech/agent/attach-unanswered-…