Nixers Book Club - Book #1: The UNIX Programming Environment - Community & Forums Related Discussions

Users browsing this thread: 1 Guest(s)
Long time nixers
It's time to bump this thread.
How was your week? Have you have a good reading?

I lost my notes for chapter 6 and 7, could not find it on my hard drive.
I probably deleted it.
Sorry about that.
I'll write what I remember from the last part of those chapters.

The main challenge of these chapters is to convert the old K&R C code into modern C code. The translation is very straight-forward if you know K&R peculiarities.
Also, the book covers something that does not work anymore: open(2)ing directories.

Chapter 7 begins with a introduction to file descriptors and low-level I/O functions like read(2) and write(2), and provides the implementation of a cat-like program called readslow(1) that reads a file while waiting for more input, similar behavior to tail -f.

Quote:Even though one call to read(2) return 0 and thus signals end of file, if more data is written on that file, a subsequent read(2) will find more bytes available. This observation is the basis of a program called readslow(1), which continues to read its input regardless of whether it got and end of file or not.

Structurally, readslow(1) is identical to cat(1) except that it loops instead of quitting when it encounters the current end of the input. It has to use low level I/O because the standard library routines continue to report EOF after the first end of file.

Then, it provides a simplified and limited implementation for cp(1).

It provides the implementation of a mail watcher using sleep() and stat() in a loop.

It then provides sv(1), a handy utility that implements the same behavior of the flag -u of GNU cp(1).

Quote:Exercise 7-15 (scapegoat).
LOL, I remember this exercise blaming Ken Thompson when I first read the book.

It implements waitfile(1), that nowadays can be implemented with inotify on Linux.

In the end, it implements timeout(1), an application that “illustrates almost everything talked about in the past two sections”

Quote:There is no detailed description of the UNIX system implementation, in part because the code is proprietary
Thank goodness we have free UNIXes now.

Sorry for the short review this week.

Messages In This Thread
RE: Nixers Book Club - Book #1: The UNIX Programming Environment - by seninha - 12-12-2020, 11:33 AM