Operating System
The interface every program has whether it asked for one or not: three descriptors it did not open, an environment it inherited, and a status code it owes its parent. Four of these chapters run in your browser, because WASI kept the descriptor numbering even though there is no operating system underneath.
- A file descriptor is an integer and nothing more. A
Filebuilt by hand out of the number 1 writes to standard output exactly as the onestdout()returns does. - Buffering belongs to your writer, not to the descriptor. Two writers on the same descriptor can deliver their bytes in the order you did not write them.
- There is no
std.posix.pipeany more. The portable way to hold one end of a pipe is to spawn a process on the other, and the way to end the conversation is to close your end. - A signal handler runs between two arbitrary instructions of whatever you were doing. Set an atomic flag and return; anything that allocates or takes a lock can deadlock the program that was holding it.
std.process.exitruns nodeferand drains no buffer. Bytes still in a writer when it is called are simply lost.
7 chapters.
- A File Descriptor Is a NumberEverything the operating system hands you to read or write is an integer.
- The Three Standard StreamsBuffering belongs to your writer, not to the descriptor underneath it.
- The EnvironmentA string-to-string map the parent process chose, handed over at startup.
- Spawning a ProcessA child is a program, an argument list, and a status code coming back.
- Pipes Are the Child's StreamsA pipe is a descriptor at each end and an end-of-file in the middle.
- SignalsA handler interrupts you between two instructions. Set a flag and return.
- Exitingexit is the process stopping, not your program returning.