Repository navigation
fix(minimald): end daemon-terminated attaches and execs with a non-zero status and a notice - #1977
Merged
Merged
Conversation
…ro status and a notice An attach the daemon ended (session destroyed, superseded by another connection, daemon shutdown) reported exit status 0, the same as a detach. It now reports 254, and a binding whose host went away prints a one-line notice like the shutdown and supersede farewells already do. An exec a daemon shutdown stops now writes "minimald is shutting down; the command was stopped" to stderr before its exit status. The check reads the sessions manager's shutdown state, now a CancellationToken shared with its handles, which is set before any session is stopped.
Contributor
|
Warning Review limit reached
This review includes 5 billable files and costs up to $1.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 24 minutes for your next included review. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (5)
Comment |
Contributor
|
Approved: no findings at Nothing to do. Clobber: none. |
mitodrummer
approved these changes
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
min session attachexits 0 when the daemon ends the attach: the session is destroyed from another terminal, another connection takes it over, or the daemon shuts down. A script cannot tell those ends from a detach. The binding teardown sentexit_status(0)for every exit reason except a shed binding.A running
min session execthatmin stop --forcekills ends with status 137 and no message, while an attached shell prints a shutdown notice in the same situation.Fix
session_host.rs: map eachMainloopExitReasonto an exit status.DetachandProcessExitedstay 0.HostGone,Superceded, andShutdownreport the newDAEMON_ENDED_EXIT_STATUS(254), documented besideSHED_EXIT_STATUS(255, unchanged). 254 is non-zero but is not ssh's 255, so the client's blind terminal unwind stays off for ends where the daemon already sent its own unwind codes.HostGonenow printsDisconnecting - the session is gone, the same way shutdown and supersede already print a farewell.sessions.rs: the manager'sin_shutdownflag becomes aCancellationTokenshared withManagerHandle, which exposesis_shutting_down(). The manager sets it before it stops any session. The server's shutdown token cannot be used here because it is cancelled only after the drain.exec.rs:ExecTask::rungoes through a newbridge_noting_shutdownwrapper. If the daemon is shutting down when the bridge returns, the wrapper writesminimald is shutting down; the command was stoppedto the stderr extended-data stream. That happens before the exit status goes out, and the command's own status is still what gets reported.docs/reference/cli-min.md: document the attach exit statuses and the exec shutdown notice.The
minclient already exits with ssh's status, so the client needs no change.Tests
New tests:
session_host::tests::daemon_ended_attaches_report_a_non_zero_exit_status:Shutdown,HostGone, andSupercededreport 254.DetachandProcessExitedreport 0, andShedreports 255.exec::tests::an_exec_ended_by_shutdown_writes_the_notice_to_stderr: a bridge that ends during shutdown writes the notice after the command's own stderr and keeps the command's status (137). A bridge that ends outside a shutdown writes no notice.Commands and results (aarch64 musl through
cross, on a macOS host):CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross test -p minimald --target aarch64-unknown-linux-musl --locked --lib -- exec:: session_host:: sessions::returned 135 passed and 2 failed. The failures wereexpose_ask_after_detaching_is_refused_by_the_live_host(shared log capture) andexpose_ask_shed_mid_dialog_is_the_daemons_refusal(a timeout under emulation load).... cross test ... -- session_host::tests::expose_ask_reran those tests in isolation: 9 passed, 0 failed.CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross clippy -p minimald --target aarch64-unknown-linux-musl --locked --all-targets -- -D warningswas clean.cargo fmt --checkwas clean.just minimal-clibuilds.I did not exercise the end-to-end attach and exec paths against a running daemon.
Refs gominimal/inbox#857