Skip to content

fix: send MSG_DETACH before exit on detach key press#11

Open
DonaldoDes wants to merge 1 commit intomobydeck:mainfrom
DonaldoDes:fix/detach-msg
Open

fix: send MSG_DETACH before exit on detach key press#11
DonaldoDes wants to merge 1 commit intomobydeck:mainfrom
DonaldoDes:fix/detach-msg

Conversation

@DonaldoDes
Copy link

Summary

  • Send MSG_DETACH to the master socket before calling exit(0) in process_kbd
  • Ensures the master clears S_IXUSR synchronously, so atch list never shows stale [attached] status

Closes #7

Test plan

  • Single session detach → list shows detached
  • Multi-session attach/detach cycle → no stale [attached]
  • Regression tests added with Python socket simulation

🤖 Generated with Claude Code

When Ctrl+\ was pressed, process_kbd called exit(0) without notifying
the master via MSG_DETACH.  The master only learned about the detach
when it received EOF on the closed fd, introducing a window where a
concurrent `atch list` could read the stale S_IXUSR bit and display
"[attached]" for a session that was already detached.

Send MSG_DETACH synchronously before calling exit(0), mirroring the
existing suspend-key (VSUSP) path.  This ensures the master clears the
S_IXUSR mode bit within one select cycle — before the client exits.

Adds regression tests (test 23) exercising the MSG_DETACH → list flow
across single and multi-session attach/detach cycles.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Detach does not send MSG_DETACH — stale attached status in list

1 participant