POSIX
This standard, first established by the Institute of Electrical and Electronics Engi-
neers (IEEE) in 1988, provided a common basis for Unix-like operating systems.
It specifies how the shell should work, what to expect from commands like ls and
grep, and a number of C libraries that C authors can expect to have available. For
example, the pipes that command-line users use to string together commands are
specified in detail here, which means C’s popen (pipe open) function is POSIX-
standard, not ISO C standard. The POSIX standard has been revised many times;
the version as of this writing is POSIX:2008, and is what I am referring to when I
say that something is POSIX-standard. A POSIX-standard system must have a C
compiler available, via the command name c99.
This book will make use of the POSIX standard, though I’ll tell you when.
With the exception of many members of a family of OSes from Microsoft, just
about every current operating system you could name is built on a POSIX-com-
pliant base: Linux, Mac OS X, iOS, webOS, Solaris, BSD—even Windows servers
offer a POSIX subsystem. And for the hold-out OSes, “Compiling C with Win-
dows” on page 6 will show you how to install a POSIX subsystem.
Finally, there are two more implementations of POSIX worth noting because of their
prevalence and influence:
BSD
After Unix was sent out from Bell Labs for researchers to dissect, the nice people
at the University of California, Berkeley, made major improvements, eventually
rewriting the entire Unix code base to produce the Berkeley Software Distribution.
If you are using a computer from Apple, Inc., you are using BSD with an attractive
graphical frontend. BSD goes beyond POSIX in several respects, and we’ll see a
function or two that are not part of the POSIX standard but are too useful to pass
up (most notably the lifesaver that is asprintf).
GNU
It stands for GNU’s Not Unix, and is the other big success story in independently
reimplementing and improving on the Unix environment. The great majority of
Linux distributions use GNU tools throughout. There are very good odds that you
have the GNU Compiler Collection (gcc) on your POSIX box—even BSD uses it.
Again, the gcc defines a de facto standard that extends C and POSIX in a few ways,
and I will be explicit when making use of those extensions.
Legally, the BSD license is slightly more permissive than the GNU license. Because some
parties are deeply concerned with the political and business implications of the licenses,
one can typically find both GNU and BSD versions of most tools. For example, both
the GNU Compiler Collection (gcc) and the BSD’s clang are top-notch C compilers.
The authors from both camps closely watch and learn from each other’s work, so we
can expect that the differences that currently exist will tend to even out over time.
Preface | xv
www.it-ebooks.info