raz / commit 3a74493e

commit
3a74493e399d3c3bf5999d2f98ec31ebd7668950
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
b1f5815f
The report, for review: Sys for rlX11 and rat (2026-10.4)

Sys gains connect, for a Unix socket such as the X server's; readyOf,
waiting on several files at once; openPty and setTermSize, for a
pseudo-terminal; spawn, wait and kill, for the programs that run on
it. PLAN.md: stage 7, the steps that make them, not started.

patch · log

2 files changed, +57 -0

PLAN.md (history) modified +26 -0

@@ -460,3 +460,29 @@
460460 `make bench` at 400,000 lines a second. Then the editors, rmacs
461461 and ravite, move their pin to this raz, in their own
462462 repositories, with their sources moved to the new operators.
463+
464+Stage 7: Sys for rlX11 and rat, report 2026-10.4
465+
466+rlX11, an X11 client library written in raz, and rat, a terminal
467+emulator over it, are to need no C: they talk to the X server over a
468+socket, and rat runs its programs on a pseudo-terminal. Sys gains what
469+that takes. Not started: each step waits for the owner's word.
470+
471+- [x] 48. The report, version 2026-10.4: `connect`, `readyOf`,
472+ `openPty`, `setTermSize`, `spawn`, `wait`, `kill` (section 11),
473+ for review before any code.
474+- [ ] 49. On Linux by system calls: `socket` and `connect` for a Unix
475+ socket; `poll` over several fds; `/dev/ptmx` with `TIOCSPTLCK`
476+ and `TIOCGPTN` for the pseudo-terminal, `TIOCSWINSZ` for its
477+ size; `fork`, then in the child `setsid`, the terminal opened as
478+ its controlling one with `TIOCSCTTY`, `dup2` to 0, 1 and 2,
479+ `close_range` for the rest, and `execve` with the environment
480+ made from this one's; `wait4`, `kill`. Over C by POSIX's names
481+ (`socket`, `poll`, `posix_openpt`, `grantpt`, `unlockpt`,
482+ `ptsname`, `fork`, `execve`, `waitpid`, `kill`), what is glibc's
483+ named in the file, as before. Both files' tests: a program
484+ spawned on a pseudo-terminal that prints its size and its
485+ arguments and ends with a status read back by `wait`; a program
486+ stopped by `kill`; `readyOf` on two pipes; `connect` refused on
487+ a path with nothing at it, and taken by a listener the test
488+ makes with Python, in `test/libc` and beside the library's own.

doc/raz.md (history) modified +31 -0

@@ -960,6 +960,15 @@
960960
961961 proc env*(name: []U8): []U8; (* the environment variable's value; "" if unset *)
962962 proc workDir*(var buf: [4096]U8): I64; (* the working directory into buf: its length *)
963+
964+proc connect*(path: []U8): I64; (* a stream socket, connected to the Unix socket at path: its fd *)
965+proc readyOf*(fds: []I64; ms: I64): I64; (* the first of fds with something to read within ms, or -1 *)
966+
967+proc openPty*: I64; (* a pseudo-terminal: the fd of its controlling side *)
968+proc setTermSize*(fd, cols, rows: I64): I64; (* the size its programs are told of *)
969+proc spawn*(path: []U8; args, env: [][]U8; tty: I64): I64; (* a program started: its process id *)
970+proc wait*(pid: I64; block: BOOL): (I64, I64); (* its status, and 1 if it has ended, 0 if not *)
971+proc kill*(pid, signal: I64): I64;
963972 ```
964973
965974 `nextEntry` gives every name in the directory except `.` and `..`, in
@@ -969,6 +978,25 @@
969978 CR to NL; and with output, NL to CR NL. A program that turns it on
970979 restores it before it ends: `Rt.atExit` is the place.
971980
981+`connect` is for talking to a server on the same machine, an X server
982+at `/tmp/.X11-unix/X0` say; what is sent and received goes by `read`
983+and `write`, and `close` ends it. `readyOf` waits on several file
984+descriptors at once, as a program does that listens to a server and a
985+terminal both.
986+
987+`openPty` makes a pseudo-terminal, a terminal that a program, a
988+terminal emulator, plays the screen and the keyboard of: what it
989+writes to the fd is typed, and what the programs on the terminal
990+write it reads. `spawn` starts the program at `path`, with `args` as
991+its arguments, the first being its name, and the environment of this
992+one with each `NAME=value` of `env` added or put in place of the old
993+value. If `tty` is a pseudo-terminal's fd, the program runs on that
994+terminal: it is its controlling terminal, and the program's standard
995+input, output and error. The program gets no other open file. `wait`
996+says whether the program has ended, waiting for it if `block`, and how:
997+its exit status, or 128 and the number of the signal that stopped it.
998+`kill` sends it a signal, 15 to end it.
999+
9721000 **Out and C's stdio.** `Out` keeps a buffer of 4 KB. It writes it out
9731001 when it is full, at each line feed when standard output is a terminal,
9741002 at `Out.flush`, and when the program ends by `Rt.exit`. C's `stdio`
@@ -1014,3 +1042,6 @@
10141042 (section 6.5). A generic module's instance is made where it is first
10151043 used, so its arguments may name types declared after the imports
10161044 (section 3).
1045+- **2026-10.4.** `Sys` gains a connection to a Unix socket, waiting on
1046+ several files at once, pseudo-terminals, and starting, waiting for
1047+ and stopping programs (section 11).