Operating System
Every program has this interface, if the program asked for it or not. The program gets three descriptors that it did not open, and an environment that it inherited. The program must return a status code to its parent. Four of these chapters run in your browser. WASI kept the descriptor numbers, but in the browser there is no operating system under WASI.
- A file descriptor is only an integer. If you make a
Fileby hand from the number 1, thatFilewrites to standard output in the same way as theFilefromstdout(). - The buffer belongs to your writer, not to the descriptor. Two writers on the same descriptor can send their bytes in a different order from the order that you wrote them.
std.posix.pipedoes not exist now. To hold one end of a pipe portably, spawn a process on the other end. To end the communication, close your end.- A signal handler runs between two arbitrary instructions of your program. Set an atomic flag and return. If the handler allocates or takes a lock, the handler can deadlock the program that held that lock.
std.process.exitruns nodeferand empties no buffer. When you callstd.process.exit, the bytes that are still in a writer are lost.
7 chapters.
- A File Descriptor Is a NumberEach thing that the operating system gives you to read or write is an integer.
- The Three Standard StreamsThe buffer belongs to your writer, not to the descriptor under the writer.
- The EnvironmentA map from string to string. The parent process selects the map, and your process gets the map at startup.
- Spawn a ProcessA child is a program, an argument list, and a status code that the parent receives.
- 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.
- Exit the Processexit stops the process. It does not return from your program.