Advanced Programming in the
UNIX Environment

by W. Richard Stevens & Stephen A. Rago
1st Edition [1st edition Buy this book]   [2nd edition, Buy this book] 2nd Edition
Addison-Wesley Professional Computing Series
1st Edition * 0-201-56317-7 * Hardcover * 768 pages * ©1992
Web/HTML/man-page-linking by: Ariel Faigon
2nd Edition * 0-201-14307-9 * Hardcover * 960 pages * ©2005


Compilation problems? Refer to the README file.
ourhdr.h: Stevens' basic definitions header file. Included in almost every example.
Stevens' portability mini-library of utility functions: 4.4BSD, SunOS, Unix SVR4
Still missing some file? It's all here. Browse the full examples directory.


Chapter 1. Introduction
Introduction * Logging In * Files and Directories * Input and Output * Programs and Processes * ANSI C Features * Error Handling * User Identification * Signals * Unix Time Values * System Calls and Library Functions * Summary


Chapter 2. Unix Standardization and Implementations
Introduction * Unix Standardization * ANSI C * IEEE POSIX * X/Open XPG3 * FIPS * Unix Implementations * System V Release 4 * 4.3+BSD * Relationship of Standards and Implementations * Limits * ANSI C Limits * POSIX Limits * XPG3 Limits * sysconf, pathconf, and fpathconf Functions * FIPS 151-1 Requirements * Summary of Limits * Indeterminate Run-Time Limits * Feature Test Macros * Primitive System Data Types * Conflicts Between Standards * Summary


Chapter 3. File I/O
Introduction * File Descriptors * open Function * creat Function * close Function * lseek Function * read Function * write Function * I/O Efficiency * File Sharing * Atomic Operations * dup and dup2 Functions * fcntl Function * ioctl Function * /dev/fd * Summary


Chapter 4. Files and Directories
Introduction * stat, fstat, and lstat Functions * File Types * Set-User-ID and Set-Group-ID * File Access Permissions * Ownership of New Files and Directories * access Function * umask Function * chmod and fchmod Functions * Sticky Bit * chown, fchown, and lchown Functions * File Size * File Truncation * Filesystems * link, unlink, remove, and rename Functions * Symbolic Links * symlink and readlink Functions * File Times * utime Function * mkdir and rmdir Functions * Reading Directories * chdir, fchdir, and getcwd Functions * Special Device Files * sync and fsync Functions * Summary of File Access Permission Bits * Summary


Chapter 5. Standard I/O Library
Introduction * Streams and FILE Objects * Standard Input, Standard Output, and Standard Error * Buffering * Opening a Stream * Reading and Writing a Stream * Line-at-a-Time I/O * Standard I/O Efficiency * Binary I/O * Positioning a Stream * Formatted I/O * Implementation Details * Temporary Files * Alternatives to Standard I/O * Summary


Chapter 6. System Data Files and Information
Introduction * Password File * Shadow Passwords * Group File * Supplementary Group IDs * Other Data Files * Login Accounting * System Identification * Time and Date Routines * Summary


Chapter 7. The Environment of a Unix Process
Introduction * main Function * Process Termination * Command-Line Arguments * Environment List * Memory Layout of a C Program * Shared Libraries * Memory Allocation * Environment Variables * setjmp and longjmp Functions * getrlimit and setrlimit Functions * Summary


Chapter 8. Process Control
Introduction * Process Identifiers * fork Function * vfork Function * exit Functions * wait and waitpid Functions * wait3 and wait4 Functions * Race Conditions * exec Functions * Changing User IDs and Group IDs * Interpreter Files * system Function * Process Accounting * User Identification * Process Times * Summary


Chapter 9. Process Relationships
Introduction * Terminal Logins * Network Logins * Process Groups * Sessions * Controlling Terminal * tcgetpgrp and tcsetpgrp Functions * Job Control * Shell Execution of Programs * Orphaned Process Groups * 4.3+BSD Implementation * Summary


Chapter 10. Signals
Introduction * Signal Concepts * signal Function * Unreliable Signals * Interrupted System Calls * Reentrant Functions * SIGCLD Semantics * Reliable Signal Terminology and Semantics * kill and raise Functions * alarm and pause Functions * Signal Sets * sigprocmask Function * sigpending Function * sigaction Function * sigsetjmp and siglongjmp Functions * sigsuspend Function * abort Function * system Function * sleep Function * Job-Control Signals * Additional Features * Summary


Chapter 11. Terminal I/O
Introduction * Overview * Special Input Characters * Getting and Setting Terminal Attributes * Terminal Option Flags * stty Command * Baud Rate Functions * Line Control Functions * Terminal Identification * Canonical Mode * Noncanonical Mode * Terminal Window Size * termcap, terminfo, and curses * Summary


Chapter 12. Advanced I/O
Introduction * Nonblocking I/O * Record Locking * Streams * I/O Multiplexing * select Function * poll Function * Asynchronous I/O * System V Release 4 * 4.3+BSD * readv and writev Functions * readn and writen Functions * Memory Mapped I/O * Summary


Chapter 13. Daemon Processes
Introduction * Daemon Characteristics * Coding Rules * Error Logging * SVR4 Streams log Driver * 4.3+BSD syslog Facility * Client-Server Model * Summary


Chapter 14. Interprocess Communication
Introduction * Pipes * popen and pclose Functions * Coprocesses * FIFOs * System V IPC * Identifiers and Keys * Permission Structure * Configuration Limits * Advantages and Disadvantages * Message Queues * Semaphores * Shared Memory * Client-Server Properties * Summary


Chapter 15. Advanced Interprocess Communication
Introduction * Stream Pipes * Passing File Descriptors * System V Release 4 * 4.3BSD * 4.3+BSD * An Open Server, Version 1 * Client-Server Connection Functions * System V Release 4 * 4.3+BSD * An Open Server, Version 2 * Summary


Chapter 16. A Database Library
Introduction * History * The Library * Implementation Overview * Centralized or Decentralized? * Concurrency * Source Code * Performance * Summary


Chapter 17. Communicating with a PostScript Printer
Introduction * PostScript Communication Dynamics * Printer Spooling * Source Code * Summary


Chapter 18. A Modem Dialer
Introduction * History * Program Design * Data Files * Server Design * Server Source Code * Client Design * Client Source Code * Summary


Chapter 19. Pseudo Terminals
Introduction * Overview * Opening Pseudo-Terminal Devices * System V Release 4 * 4.3+BSD * pty_fork Function * pty Program * Using the pty Program * Advanced Features * Summary


Appendix A. Function Prototypes (NA in source)

Appendix B. Miscellaneous Source Code
Our Header File * Standard Error Routines

Appendix C. Solutions to Selected Exercises

Bibliography (NA in source)

Index (NA in source)


Comments to: