Why are there two versions of the example programs?
The example programs for The Linux Programming Interface
are provided in two versions:
A distribution version, which includes extra
material that is not shown in the book version.
A book version,
which shows the program exactly as it appears in the book.
Differences between the distribution and book versions
occur for the following reasons:
In some cases, extra comments are included in the
distribution version of the code.
These comments allow the program to be read more easily in
isolation from the book.
The distribution versions of some of the programs
includes extra code that helps make the programs more
portable to non-Linux systems.
(This code was excluded from the book versions of the
programs in order to keep the book versions shorter,
and also because the extra code is sometimes
nonportable and system-specific.)
Comments in the distribution version explain the purpose
of this added code and the systems to which it applies.
The distribution versions of a few of the programs
includes extra code that allows the programs to
run on older Linux systems.
The most common example is code that conditionally
defines constants that may not be defined in
the header files in older glibc versions.
(This code was excluded from the book versions of the
programs in order to keep the book versions shorter.)
The distribution version of a few of the programs
provides extra functionality beyond that of the book version.
The distribution version thus provides further detail
beyond that available in the book version.
(Generally, the book version was made shorter so that
it occupied less page space in the book, while still being
sufficient to demonstrate the essential concepts.)