| | @@ -960,6 +960,15 @@ |
| 960 | 960 | |
| 961 | 961 | proc env*(name: []U8): []U8; (* the environment variable's value; "" if unset *) |
| 962 | 962 | 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; |
| 963 | 972 | ``` |
| 964 | 973 | |
| 965 | 974 | `nextEntry` gives every name in the directory except `.` and `..`, in |
| | @@ -969,6 +978,25 @@ |
| 969 | 978 | CR to NL; and with output, NL to CR NL. A program that turns it on |
| 970 | 979 | restores it before it ends: `Rt.atExit` is the place. |
| 971 | 980 | |
| 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 | + |
| 972 | 1000 | **Out and C's stdio.** `Out` keeps a buffer of 4 KB. It writes it out |
| 973 | 1001 | when it is full, at each line feed when standard output is a terminal, |
| 974 | 1002 | at `Out.flush`, and when the program ends by `Rt.exit`. C's `stdio` |
| | @@ -1014,3 +1042,6 @@ |
| 1014 | 1042 | (section 6.5). A generic module's instance is made where it is first |
| 1015 | 1043 | used, so its arguments may name types declared after the imports |
| 1016 | 1044 | (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). |