Description
When pressing the detach character (Ctrl+), the client prints the detach message and calls exit(0) without sending MSG_DETACH to the master. The master only learns about the disconnect via EOF on the socket, creating a race condition where atch list can show the session as [attached] after detach.
Reproduction
- Create session1 and session2
- Attach session1, detach (Ctrl+)
- Attach session2, detach (Ctrl+)
atch list → session2 may still show [attached]
Root cause
process_kbd in attach.c calls exit(0) on detach_char without first sending MSG_DETACH to the master. The VSUSP path correctly sends the message, but the detach path does not.
Suggested fix
Send MSG_DETACH to the master socket before exit(0) in the detach_char handler.