raz / commit 24955285

commit
249552856c324bc3ad8d88e53430fca910dd019b
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
ebbd9966
The report: Sys.send, writing to a socket without SIGPIPE (2026-10.7)

write to a socket whose other end has closed stops the program with
SIGPIPE; send returns -32 (EPIPE) instead, so that rlX11 can say its
X server has gone. Asked for by the owner.

patch · log

1 file changed, +9 -2

doc/raz.md (history) modified +9 -2

@@ -978,6 +978,7 @@
978978 proc workDir*(var buf: [4096]U8): I64; (* the working directory into buf: its length *)
979979
980980 proc connect*(path: []U8): I64; (* a stream socket, connected to the Unix socket at path: its fd *)
981+proc send*(fd: I64; s: []U8): I64; (* write, to a socket: -32 (EPIPE), not a signal, if it is closed *)
981982 proc readyOf*(fds: []I64; ms: I64): I64; (* the first of fds with something to read within ms, or -1 *)
982983
983984 proc openPty*: I64; (* a pseudo-terminal: the fd of its controlling side *)
@@ -1000,8 +1001,12 @@
10001001 restores it before it ends: `Rt.atExit` is the place.
10011002
10021003 `connect` is for talking to a server on the same machine, an X server
1003-at `/tmp/.X11-unix/X0` say; what is sent and received goes by `read`
1004-and `write`, and `close` ends it. `readyOf` waits on several file
1004+at `/tmp/.X11-unix/X0` say; what it receives comes by `read`, what it
1005+sends goes by `send`, and `close` ends it. `send` is `write` for a
1006+socket, except when the other end has closed it: `write` would stop
1007+the program with the signal SIGPIPE, where `send` returns -32
1008+(EPIPE), so that a program learns its server has gone and can end as
1009+it wants. `readyOf` waits on several file
10051010 descriptors at once, as a program does that listens to a server and a
10061011 terminal both.
10071012
@@ -1070,4 +1075,6 @@
10701075 directories searched is an error, unless the first is a link to one
10711076 of the others (section 3).
10721077 - **2026-10.6.** `Sys.Info` says whether the path is a symbolic link
1078+ (section 11).
1079+- **2026-10.7.** `Sys.send` writes to a socket without SIGPIPE
10731080 (section 11).