mirror of
https://github.com/HeyPuter/gex.git
synced 2026-11-13 20:12:43 -10:00
sys.listen(path) binds a unix socket name (an absolute path, or an abstract name with a leading NUL) in the kernel's socket table as a program's bind and listen do, with the socket file at the path; each program's connect is a connection the page takes (accept, or for await, whose end closes the listener). Made before boot, it is bound as the kernel comes up, before pid 1. A stale socket file is replaced; another file or a bound name is EADDRINUSE. close() lets the name go: a program's connect is refused, the file stays. sys.connect(path) connects to a program's listener: ECONNREFUSED, or ENOENT with no file there. The page's ends are the kernel's own sockets (k_sock_*), the ones programs' AF_UNIX streams are, so poll, select and epoll see them as any other; no kernel or guest change. GuestConnection (connectGuest's too) now waits on each write until the socket takes it (it returned at once, and writes could interleave), rejects a write after the far end closed (EPIPE), keeps writing after the program's shutdown(SHUT_WR) (a readable at its end let the whole connection go), and an abort while a write waits closes at once. README: a Unix sockets section (two examples, run by core/readme against the slim image's perl). Test core/unix with fixtures/probe/rt-unix.c: before and after boot, half close both ways, three at once both ways, 64 MiB with a pausing reader, a page writer held by a program not reading, abort (EPIPE), a killed program, abstract names, EADDRINUSE/ENOENT, close then ECONNREFUSED and listening again, SOCK_SEQPACKET as a stream, SOCK_DGRAM refused. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_e0aa53aa95eb4b86910519b4d14812a5 (cherry picked from commit c93ab84a852741aabc5c434289d5d41b57dbbfa4)