Skip to content

attach: do not discard the shell exit status when stdin closes first - #414

Open
dob323 wants to merge 1 commit into
shell-pool:masterfrom
dob323:fix/attach-exit-status
Open

attach: do not discard the shell exit status when stdin closes first#414
dob323 wants to merge 1 commit into
shell-pool:masterfrom
dob323:fix/attach-exit-status

Conversation

@dob323

@dob323 dob323 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

The attach client stamps its fallback exit status of 1 into the result slot as soon as EITHER pipe thread finishes. A terminal that closes the client stdin before the shell ExitStatus frame arrives therefore reported 1 no matter how the shell exited. This waits the existing bounded detach window (MAX_DETACH_WAIT_DUR) for the socket side before defaulting; the wait returns as soon as the frame lands, so a normal exit is unaffected.

Regression test regression::stdin_close_does_not_discard_exit_status: closes the client stdin while the shell is still sleeping toward exit 19. On master the client reports 1; patched it reports 19.

Running in production under our session manager for a week alongside #413. AI disclosure per the practice on #406: drafted with an AI assistant, reviewed and tested by a human before submission.

@ethanpailes ethanpailes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, mind rebasing?

Comment thread libshpool/src/protocol.rs
+ (sock_to_stdout_h.is_finished() as usize);

if nfinished_threads > 0 {
// A finished stdin->sock thread only means our local input

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment is good but overly verbose, can you edit it down a bit?

@ethanpailes

Copy link
Copy Markdown
Contributor

Oh, also, for all of these PRs, can you follow canonical commits? Since these are all non-breaking bugfixes, they should all start with fix:

The client stamps its fallback exit status of 1 into the result slot as
soon as EITHER pipe thread finishes. A terminal that closes the client's
stdin before the shell's ExitStatus frame arrives therefore reported 1 no
matter how the shell exited. Wait the existing bounded detach window for
the socket side before defaulting; the wait returns as soon as the frame
lands, so a normal exit is unaffected.

Regression test: close the attach client's stdin while the shell is still
sleeping toward exit 19; on master the client reports 1, patched it
reports 19.
@dob323
dob323 force-pushed the fix/attach-exit-status branch from 4975fb1 to de1eeba Compare August 17, 2026 20:15
@dob323

dob323 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Done across the set: #406, #413, #414, and #415 are all single fix:-prefixed commits now (the rustfmt fixup on #406 got squashed in while I was at it).

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