File I/O from the Linux Programming Interface book - summary
- files are central to the UNIX philosophy...
- all system calls refer to files through "file descriptors" (small non negative numbers)
- 0, 1, 2 fd's, they are stdin, stdout and stderr (these are the standard ones that a shell uses...)
- main system calls are;
- open()
if an error happens in the open() call it always returns -1, and the identification of an error.
- read()
- write()
- close()
the close() call always closes all open file descriptors so that the process can continue to use them.
These four system calls can be used to operate on all types of files in Linux like devices or terminals.