TestDoorSession failed about once in 100-200 runs, two ways:
- "fork/exec door.sh: permission denied": the server made unix sockets
under a umask of 0177, and the umask is the whole process's. A file
made by another goroutine meanwhile lost its mode: here the test's
door script, written as the server started, came out 0600. In the
BBS the same could befall anything made while a listener started.
The socket is now made in a private directory beside its place, given
its mode and group there, then renamed into place: still no moment
when others could connect, and no umask touched. Closing the
listener removes the socket.
- the door's last output lost ("Bye from the door" never came): a door
without a pty wrote to cmd.StdoutPipe, which Wait closes as soon as
the door exits, while the reader may not have drained it. The door
now writes to a pipe of the runner's own, read to its end.
TestOutputAfterExit (door) lost 28-48 KB of a door's last output on
every run before; TestSocketLeavesUmask (server) saw 0755 files made
0600 within a few dozen tries. Both pass now, and TestDoorSession
passed 500 runs in a row under -race.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr