⚡ Zig Guide LiveUnofficialbut fully verified
✓ Zig 0.18.0-dev.738+ae9a8acc7What's newOn an older Zig?Blograylib-zig

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.

  1. A file descriptor is only an integer. If you make a File by hand from the number 1, that File writes to standard output in the same way as the File from stdout().
  2. 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.
  3. std.posix.pipe does 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.
  4. 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.
  5. std.process.exit runs no defer and empties no buffer. When you call std.process.exit, the bytes that are still in a writer are lost.

7 chapters.