17-11-2012, 04:39 PM
UNIX programming
Advanced UNIX Programming Richard Stevens.pdf (Size: 1.6 MB / Downloads: 42)
Introduction
This is a book about UNIX programming. It starts with basic concepts and ends with
coverage of advanced topics. It is a self-teaching guide, and yet it functions as a
UNIX reference book.
The examples provided are written in the C and C++ languages. The examples are
short programs, each intended to demonstrate use of a particular programming facility.
The C++ programs are written as simple programs and should be well understood by
those that do not program in C++.
This book attempts to be UNIX platform neutral. Throughout the book, differences in
functionality are noted for your convenience. This will save you time when you must
write projects that must be UNIX portable.
FreeBSD 3.4 release is used throughout this book for demonstration purposes. This
guarantees that the example programs will compile and run without any additional
effort on that platform. This also grants a specific level of functionality, since some
functions are lacking or vary on other platforms. You can obtain FreeBSD from the
Internet or purchase it on a CD-ROM at a nominal cost. This allows you to work
through the book on a platform that is on a par with other professional UNIX
platforms
Compiler Notes and Options
You are reading this book because you want to write software for UNIX. Perhaps you
are interested in developing software to run on several UNIX platforms. Whether you
must write for several platforms or a few, writing your software to compile
successfully for each UNIX platform is a challenge. This chapter is aimed at reducing
that challenge and improving your success rate. Additionally, you will find some
valuable Internet resources in this chapter, along with some cross-platform examples
and advice.
Online Manual Pages
Throughout this text, you will see references to online documents that exist on most
UNIX systems. These online documents save the programmer a great deal of time
when he is writing programs. Rather than fetch a book and look in the index for the
correct page, you can pull up the information within seconds, instead. This electronic
documentation can be brought into an editor, or segments of it can be cut and pasted
using the normal X Window facilities. For this reason, this text places some emphasis
on online manual page references for your convenience.
The C Compile Command
Most UNIX platforms invoke their C compilers by the name cc. Linux and FreeBSD
platforms support the gcc command name in addition to the standard cc name.
Sometimes the GNU compiler will be installed as gcc on commercial platforms to
distinguish it from the standard offering or in addition to the crippled (non-ANSI) one.
For example, HP includes a non-ANSI compiler with the HPUX operating system,
which is called the "bundled" compiler (this compiler is sufficient to rebuild a new
HPUX kernel). The ANSI-capable compiler must be purchased separately and, when
installed, replaces the bundled cc command.