Unix File Descriptors
Unix processes name I/O and IPC objects by integers known as file descriptors.
- File descriptors 0, 1, and 2 are reserved by convention for standard input, standard output, and standard error.
“Conforming” Unix programs read input from stdin, write output to stdout, and errors to stderr by default.
- Other descriptors are assigned by syscalls to open/create files, create pipes, or bind to devices or network sockets.
pipe, socket, open, creat
- A common set of syscalls operate on open file descriptors independent of their underlying types.