Skip to content

[v1] send exit-status from the example servers - #686

Merged
puellanivis merged 1 commit into
pkg:masterfrom
christhomas:example-exit-status
Oct 19, 2026
Merged

puellanivis merged 1 commit into
pkg:masterfrom
christhomas:example-exit-status

Conversation

@christhomas

Copy link
Copy Markdown
Contributor

For #321.

Server and RequestServer only see an io.ReadWriteCloser, so the exit-status channel request has to come from whoever owns the SSH channel, the same way server_integration_test.go already does it. The two example servers never sent it, and some clients (restic, for example) wait for it before they consider the session finished. This sends it after Serve returns: 0 on a clean exit (nil or io.EOF), 1 otherwise.

I checked both examples with a small client that opens the subsystem, half-closes the channel like OpenSSH's sftp does, and waits for the request: master closes the channel without an exit-status, and with this change both send exit-status 0.

Since the library can't send this itself, I think #321 can be closed once the examples show how to do it.

The SFTP subsystem's exit status is sent by whoever owns the SSH
channel, since Server and RequestServer only see an io.ReadWriteCloser.
The example servers never sent it, and some clients (restic, for
example) wait for it before they consider the session finished. Send
it after Serve returns, the same way the server integration tests
already do.
if err != nil {
exitStatus = 1
}
channel.SendRequest("exit-status", false, ssh.Marshal(struct{ Status uint32 }{exitStatus}))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One would figure that these standardized and defined request packets would be kept somewhere that everyone could use them consistently…

https://www.rfc-editor.org/info/rfc4254/#section-6.10

@puellanivis
puellanivis merged commit 4778ed9 into pkg:master Oct 19, 2026
4 checks passed
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.

2 participants