(使用的是2005年的英文第二版,
"One of the essential classics of UNIX programming."
—Eric S. Raymond, author of The Art of UNIX Programming
Forward by Dennis Ritchie:..."It's a most worthy second edition of a classic."...
0.Preface
主要是简要的介绍了一下Unix以及本书的写作背景与历史,介绍了本书的基本内容。
“This book describes theprogramming interface to the Unix system, thesystem call interface and many of the functions provided in thestandard C library. It is intended for anyone writing programs that run under Unix.”
Organization of the book:
1, Overview & introduction: ch1;
Unix Standardization: ch2;
2, I/O, files, I/O library: ch3~6;
3, processes, signals: ch7~10;
4, I/O terminal,advanced I/O: ch11~13;
5, IPC: ch14~15;
6, examples: ch16~19.
"This text is intended for programmers familiar with Unix and programmers familiar with some other operating system who wish to learn the details of the services provided by most Unix systems."
本书中的所有近10000行代码都是用C写的。
Chapter 1. UNIX System Overview
1.1 Intro
The focus of this text is to describe the services provided by various versions of the UNIX operating system.
1.2 Architecture
In a strict sense, an operating system can be defined as the software that controls the hardware resources of the computer and provides an environment under which programs can run.
The interface to the kernel is a layer of software called thesystem calls (the shaded portion inFigure 1.1). Libraries of common functions are built on top of the system call interface, but applications are free to use both. The shell is a special application that provides an interface for running other applications.
1.3 Logging in
When we log in to a UNIX system, we enter our login name, followed by our password. The system then looks up our login name in its password file, usually the file/etc/passwd.
Shells: Ashell is a command-line interpreter that reads user input and executes commands. The user input to a shell is normally from the terminal (an interactive shell) or sometimes from a file (called ashell script).
1.4 Files and Directories
File System:
A directory is a file that contains directory entries. Logically, we can think of each directory entry as containing a filename along with a structure of information describing the attributes of the file.
Filename & Pathname
The names in a directory are calledfilenames. The only two characters that cannot appear in a filename are the slash character (/) and the null character.
A sequence of one or more filenames, separated by slashes and optionally starting with a slash, forms apathname. A pathname that begins with a slash is called anabsolute pathname; otherwise, it's called arelative pathname.
Working directory & Home directory:This is the directory from which all relati