UNIX環(huán)境高級編程

出版時間:2002-1-1  出版社:機械工業(yè)出版社  作者:W.Richard Stevens  頁數(shù):744  
Tag標簽:無  

內容概要

If you are an experienced C programmer with a working knowledge of UNIX, you cannot afford to be without this up-to -date tutorial on the system call interface and the most important functions found in the ANSI C library. Richard Stevens describes more than 200 system calls and functions; since he believes the best way to learn code is to read code,a brief example accompanies each description. Building upon information presented in the first 15 chapters, the author offers chapter-long examples teaching you how to create a database library, a PostScript printer driver, a modem dialer, and a program that runs other programs under a pseudo terminal. To make your analysis and understanding ofthis code even easier, and to allow you to modify it, all of the code in the book is available via UUNET. Advanced Programming in the UNIX Environment is applicable to all major UNIX releases, especially System V Release $ and the latest release of 4.3BSD, including 386BSD. These real-world implementations allow you to more clearly understand the status of the current and future standards,including IEEE POSIX and XPG3.

書籍目錄

Chapter 1. Introduction
1.1 Introduction
1.2 Logging In
1.3 Files and Directories
1.4 Input and Output
1.5 Programs and Processes
1.6 ANSI C Features
1.7 Error Handling
1.8 User Identification
1.9 Signals
1.10 Unix Time Values
1.11 System Calls and Library Functions
1.12 Summary
Chapter 2. Unix Standardization and Implementations
2.1 Introduction
2.2 Unix Standardization
2.3 Unix Implementations
2.4 Relationship of Standards and Implementations
2.5 Limits
2.6 Feature Test Macros
2.7 Primitive System Data Types
2.8 Conflicts Between Standards
2.9 Summary
Chapter 3. FiIe I/O
3.1 Introduction
3.2 File Descriptors
3.3 open Function
3.4 creat Function
3.5 close Function
3.6 lseek Function
3.7 read Function
3.8 write Function
3.9 I/O Efficiency
3.10 File Sharing
3.11 Atomic Operations
3.12 dup and dup2 Functions
3.13 fcntl Function
3.14 ioctl Function
3.15 /dev/fd
3.16 Summary
Chapter 4. Files and Directories
4.1 Introduction
4.2 stat, fstat, and lstat Functions
4.3 File Types
4.4 Set-User-ID and Set-Group-lD
4.5 File Access Permissions
4.6 Ownership of New Files and Directories
4.7 access Function
4.8 umask Function
4.9 chmod and fchmod Functions
4.10 Sticky Bit 88
4.11 chown, fchown, and lchown Functions
4.12 File Size
4.13 File Truncation
4.14 Fijesystems
4.15 link, unlink, remove, and rename Functions
4.16 Symbolic Links
4.17 symlink and readlink Functions
4.18 File Times
4.19 utime Function
4.20 mkdir and rmdir Functions
4.21 Reading Directories
4.22 chdir, fchdir, and getcwd Functions
4.23 Special Device Files
4.24 sync and fsync Functions
4.25 Summary of File Access Permission Bits
4.26 Summary
Chapter 5. Standard I/O Library
5.1 Introduction
5.2 Streams and FILE Objects
5.3 Standard Input, Standard Output, and Standard Error
5.4 Buffering
5.5 Opening a Stream
5.6 Reading and Writing a Stream
5.7 Line-at-a-Time I/O
5.8 Standard I/O Efficiency
5.9 Binary I/O
5.10 Posltioning a Stream
5.11 Formatted I/O
5.12 Implementation Details
5.13 Temporary Files
5.14 Alternatives to Standard I/O
5.15 Summary
Chapter 6. System Data Files and Information
6.1 Introduction
6.2 Password File
6.3 Shadow Passwords
6.4 Group File
6.5 Supplementary Group IDs
6.6 Other Data Files
6.7 Login Accounting
6.8 System Identification
6.9 Time and Date Routines
6.10 Summary
Chapter 7. The Environment of a Unix Process
7.1 Introduction
7.2 main Function
7.3 Process Termination
7.4 Command-Line Arguments
7.5 Environment List
7.6 Memory Layout of a C Program
7.7 Shared Libraries
7.8 Memory Allocation
7.9 Environment Variables
7.10 set jmp and ionqjmp Functions
7.11 qetrlimit and setrlimit Functions
7.12 Summary
Chapter 8. Process Control
8.1 Introduction
8.2 Process Identifiers
8.3 fork Function
8.4 vfork Function
8.5 exit Functions
8.6 wait and waitpid Functions
8.7 wait3 and wait4 Functions
8.8 Race Conditions
8.9 exec Functions
8.10 Changing User IDs and Group IDs
8.11 Interpreter Files
8.12 system Function
8.13 Process Accounting
8.14 User Identification
8.15 Process Times
8.16 Summary
Chapter 9. Process Relationships
9.1 Introduction
9.2 Terminal Logins
9.3 Network Logins
9.4 Process Groups
9.5 Sessions
9.6 Controlling Terminal
9.7 tcgetpqrp and tcsetpgrp Functions
9.8 Job Control
9.9 Shell Execution of Programs
9.10 Orphaned Process Groups
9.11 4.3+BSD Implementation
9.12 Summary
Chapter 10. Signals
10.1 Introduction
10.2 Signal Concepts
10.3 signal Function
10.4 Unreliable Signals
10.5 Interrupted System Calls
10.6 Reentrant Functions
10.7 SIGCLD Semantics
10.8 Reliable Signal Terminology and Semantics
10.9 kill and ra1se Functions
10.10 alarm and pause Functions
10.11 Signal Sets
10.12 siqprocmask Function
10.13 siqpending Function
10.14 sigaction Function
10.15 sigsetjmp and siglongjmp Functions
10.16 siqsuspend Function
10.17 abort Function
10.18 system Function
10.19 sleep Function
10.20 Job-Control Signals
10.21 Addltional Features
10.22 Summary
Chapter 11. Terminal I/O
11.1 Introduction
11.2 Overview
11.3 Special Input Characters
11.4 Getting and Setting Terminal Attributes
11.5 Terminal Option Flags
11.6 stty Command
11.7 Baud Rate Functions
11.8 Line Control Functions
11.9 Terminal Identification
11.10 Canonical Mode
11.11 Noncanonical Mode
11.12 Terminal Window Size
11.13 termcap, terminfo. and curses
11.14 Summary
Chapter 12. Advanced I/O
12.1 Introduction
12.2 Nonblocking I/O
12.3 Record Locking
12.4 Streams
12 5 I/O Multiplexing
12.6 Asynchronous I/O
12.7 readv and writev Functions
12.8 readn and writen Functions
12.9 Memory Mapped I/O
12.10 Summary
Chapter 13. Daemon Processes
13.1 Introduction
13.2 Daemon Characteristics
13.3 Coding Rules
13.4 Error Loggjng
13.5 Client-Server Model
13.6 Summary
Chapter 14. Interprocess Communication
14.1 Introduction
14.2 Pipes
14.3 popen and pciose Functions
14.4 Coprocesses
14.5 FIFOs
14.6 System V IPC
14.7 Message Queues
14.8 Semaphores
14.9 Shared Memory
14.10 Client-Server Properties
14.11 Summary
Chapter 15. Advanced Interprocess Communication
15.1 Introduction
15.2 Stream Pipes
15.3 Passing File Descriptors
15.4 An Open Server, Version 1
15.5 Client--Server Connection Functions
15.6 An Open Server, Version 2
15.7 Summary
Chapter 16. A Database Library
16.1 Introduction
16.2 History
16.3 The Library
16.4 Implementation Overview
16.5 Centralized or Decentralized?
16.6 Concurrency
16.7 Source Code
16.8 Performance
16.9 Summary
Chapter 17. Communicating with a PostScript Printer
17.1 Introduction
17.2 PostScript Communication Dynamics
17.3 Printer Spooling
17.4 Source Code
17.5 Summary
Chapter 18. A Modem Dialer
18.1 Introduction
18.2 History
18.3 Program Design
18.4 Data Files
18.5 Server Design
18.6 Server Source Code
18.7 Client Design
18.8 Client Source Code
18.9 Summary
Chapter 19. Pseudo Terminals
19.1 Introduction
19.2 Overview
19.3 Opening Pseudo-Terminal Devices
19.4 pty_fork Function
19.5 pty Program
19.6 Using the pty Program
19.7 Advanced Features
19.8 Summary
Appendix A. Function Prototypes
Appendix B. Miscellaneous Source Code
B.1 Our Header File
B.2 Standard Error Routines
Appendix C. Solutions to Selected Exercises
Bibliography
Index

圖書封面

圖書標簽Tags

評論、評分、閱讀與下載


    UNIX環(huán)境高級編程 PDF格式下載


用戶評論 (總計11條)

 
 

  •     APUE、UNP兩卷,這三本書應該是進入linux編程的必讀之書,如果真正讀完這三本書,并且認真思考過,再加上一些項目的練習,那么你會成為一個能做事的程序員,你會有能力單獨完成一個不算復雜的項目;但是也僅僅是一個能做事的程序員而已,離一個優(yōu)秀的程序員還很遠。
  •     我看這本書的目的就是更加深入地理解Unix,讀得不是很細,但也從中學到很很多基礎且重要的知識。書中大量的實例代碼,對于知識的理解和平時的查閱非常有用。稍微不足的地方是整本書在在講述概念的時候比較官方,比喻、圖示等人類更容易理解的方式用的還不是特別多。
  •     這本書不錯。不過自學起來有地方不懂,搞不明白,怪累的。有朋友說在獵豹網(wǎng)校上學這個課程,是看視頻那種,挺容易看懂的,就象有個老師面對面講課操作給我看一樣。我就也上去試聽了一下,老師講的還真不錯,聽一下,真是就簡單多了!象我這樣上班三班倒的人,沒有大塊時間,下了班隨時找點空,就上網(wǎng)聽幾下,就能學下來了。
      
  •     第21章,與網(wǎng)絡打印機通信
      
      printd.c的代碼中,從863到878行,如果讀的緩沖區(qū)剛好在"Content-Length:xxxx"(xxxx代表一個數(shù)字)中的數(shù)字部分截斷,那得到的content-length就不是真實長度了。
      
      求證。
  •     這本書很棒,真的。
      可惜作者死掉了。
      很喜歡書中例子簡明,但靠他搞不定事情。我是指編程技巧,可能還需要一些算法方面的書,比如The art of computtting programming.
      
      這本書里面的File概念在大多數(shù)動態(tài)語言中有著相似的實現(xiàn),當然要方便許多。
      當你某天在python中看到select系統(tǒng)調用,你會淚流滿面的想到APUE:
      They are exactly the same thing!!!!!!!
      
      Signal這一章有點亂,當然不通種的*unix在上面刀光劍影的事情太多了。
      reentra沒看懂,但是wiki上面的reentrant有個甚好的補充。
      
      Thread避免了不同task之間的序列化,用起來很棒,但是sync除外。
      
      說說sync吧:
      在C里,sync是件麻煩時,因為要考慮signal和thread的交互影響,好像一個不小心就deadlock,感覺像是走在鋼絲線上,一個不慎萬劫不復。如果要考慮各種情況的話,就有點想玩排列組合,這真的很累哦。
      我想有沒有數(shù)學方法可以在編程中借鑒,對于這些事務進行處理?
      
      說實話,書中對程序中的數(shù)據(jù)加lock進行保護的方法真的不怎么好。
      如果這些數(shù)據(jù)一多--lock同樣的增多,在非良構的程序中,程序出錯的機率大大增加。即使在良構的程序中,這些lock也要占用大量的系統(tǒng)資源。
      
      對于上述情況,現(xiàn)在的程序的做法,好像是對于thread進行限制,讓他只能接觸自己的數(shù)據(jù),不同thread的之間通過消息來傳遞數(shù)據(jù)。想想html5中的worker吧,post message或者是get message來和主線程通信。說實在話,全局的資源還是有沖突的可能,但是這至少是事情變得省心的開始。
      
      也許erlang, clojure這些functional language在這條路上走的更遠。這些是程序世界的迷人之處,小的變革,影響世界。
      
      
      
      BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,BULA,
  •     Mon Nov 08 , 2010 Beijing
      剛剛拜讀完UNIX環(huán)境高級編程-(第2版),感受如下:
      1,詳細描述標準ISO C 以及POSIX.1 庫的介紹還有具體應用;
      2,分別針對Linux,Unix,Solaris 系統(tǒng)上C編程做了詳細描述
  •   真要是那么巧的中斷在數(shù)字部分,content-length 就gg了
  •   這個概率不小吧。那gg也太容易了
  •   嗯,要是斷在這確實比較慘~ 不過我認為概率真不大~ 他每次讀取的數(shù)據(jù)應該可以最少包含一個完整的http請求,除非超時或者被中斷 這時候就當做錯誤處理了~
  •   恩,你說的也對。我剛查了下,代碼里一次讀的大小是8k,想必也夠一個http頭了。我是受代碼中大量的readmore的影響了。
  •   是 mesg truancation !
 

250萬本中文圖書簡介、評論、評分,PDF格式免費下載。 第一圖書網(wǎng) 手機版

京ICP備13047387號-7