April 2004
Intermediate to advanced
736 pages
16h 19m
English
In this chapter we’ll explore basic I/O on regular files. The I/O story continues in Chapter 3 with more advanced I/O system calls. I/O on special files is in Chapter 4, I/O on pipes in Chapter 6, I/O on named pipes in Chapter 7, and I/O on sockets in Chapter 8.
To get started I’ll show a simple example that uses four system calls you may already be familiar with: open, read, write, and close. This function copies one file to another (like the cp command):

Try to find the bug in this function (there’s a clue in Section 1.4.1). If you can’t, I’ll point it out in Section 2.9.
I’ll say just a few quick ...
Read now
Unlock full access