UNIX环境高级编程

W.Richard Stevens St

文学

unix 编程 Programming linux Linux/Unix 计算机 APUE 经典

2006-2

人民邮电出版社

目录
Chapter 1. UNIX System Overview 1 1.1 Introduction 1 1.2 UNIX Architecture 1 1.3 Logging In 2 1.4 Files and Directories 4 1.5 Input and Output 8 1.6 Programs and Processes 10 1.7 Error Handling 14 1.8 User Identification 16 1.9 Signals 18 1.10 Time Values 20 1.11 System Calls and Library Functions 21 1.12 Summary 23 Chapter 2. UNIX Standardization and Implementations 25 2.1 Introduction 25 2.2 UNIX Standardization 25 2.2.1 ISO C 25 2.2.2 IEEE POSIX 26 2.2.3 The Single UNIX Specification 29 2.2.4 FIPS 33 2.3 UNIX System Implementations 33 2.3.1 UNIX System V Release 4 33 2.3.2 4.4BSD 34 2.3.3 FreeBSD 35 2.3.4 Linux 35 2.3.5 Mac OS X 35 2.3.6 Solaris 35 2.3.7 Other UNIX Systems 36 2.4 Relationship of Standards and Implementations 36 2.5 Limits 36 2.5.1 ISO C Limits 38 2.5.2 POSlX Limits 38 2.5.3 XSl Limits 40 2.5.4 sysconf, pathconf, and fpathconf Functions 41 2.5.5 Indeterminate Runtime Limits 48 2.6 Options 52 2.7 Feature Test Macros 55 2.8 Primitive System Data Types 56 2.9 Conflicts Between Standards 56 2.10 Summary 58 Chapter 3. File I/0 59 3.1 Introduction 59 3.2 File Descriptors 59 3.3 open Function 60 3.4 creat Function 62 3.5 close Function 63 3.6 1 seek Function 63 3.7 read Function 67 3.8 write Function 68 3.9 I/O Efficiency 68 3.10 File Sharing 70 3.11 Atomic Operations 74 3.12 dup and dup2 Functions 76 3.13 sync, fsync, and fdatasync Functions 77 3.14 fcnt 1 Function 78 3.15 ioct 1 Function 83 3.16 /dev/fd 84 3.17 Summary 85 Chapter 4. Files and Directories 87 4.1 Introduction 87 4.2 stat, fstat, and lstat Functions 87 4.3 File Types 88 4.4 Set-User-ID and Set-Group-ID 91 4.5 File Access Permissions 92 4.6 Ownership of New Files and Directories 95 4.7 access Function 95 4.8 umask Function 97 4.9 chmod and f chmod Functions 99 4.10 Sticky Bit 101 4.11 chown, fchown, and lchown Functions 102 4.12 File Size 103 4.13 File Truncation 105 4.14 File Systems 105 4.15 link, unlink, remove, and rename Functions 108 4.16 Symbolic Links 112 4.17 syml ink and readlink Functions 115 4.18 File Times 115 4.19 ut ime Function 116 4.20 mkdir and rmdir Functions 119 4.21 Reading Directories 120 4.22 chdir, fchdir, and getcwd Functions 125 4.23 Device Special Files 127 4.24 Summary of File Access Permission Bits 130 4.25 Summary 130 Chapter 5. Standard I/O Library 133 5.1 Introduction 133 5.2 Streams and FILE Objects 133 5.3 Standard Input, Standard Output, and Standard Error 135 5.4 Buffering 135 5.5 Opening a Stream 138 5.6 Reading and Writing a Stream 140 5.7 Line-at-a-Time I/O 142 5.8 Standard I/O Efficiency 143 5.9 Binary I/O 145 5.10 Positioning a Stream 147 5.11 Formatted I/O 149 5.12 Implementation Details 153 5.13 Temporary Files 155 5.14 Alternatives to Standard I/O 159 5.15 Summary 159 Chapter 6. System Data Files and Information 161 6.1 Introduction 161 6.2 Password File 161 6.3 Shadow Passwords 165 6.4 Group File 166 6.5 Supplementary Group IDs 167 6.6 Implementation Differences 169 6.7 Other Data Files 169 6.8 Login Accounting 170 6.9 System Identification 171 6.10 Time and Date Routines 173 6.11 Summary 177 Chapter 7. Process Environment 179 7.1 Introduction 179 7.2 main Function 179 7.3 Process Termination 180 7.4 Command-Line Arguments 185 7.5 Environment List 185 7.6 Memory Layout of a C Program 186 7.7 Shared Libraries 188 7.8 Memory Allocation 189 7.9 Environment Variables 192 7.10 set j mp and longj mp Functions 195 7.11 getrlimit and setrlimit Functions 202 7.12 Summary 206 Chapter 8. Process Control 209 8.1 Introduction 209 8.2 Process Identifiers 209 8.3 fork Function 211 8.4 vfork Function 216 8.5 exit Functions 218 8.6 wait and waitpid Functions 220 8.7 waitid Function 226 8.8 wait3 and wait4 Functions 227 8.9 Race Conditions 227 8.10 exec Functions 231 8.11 Changing User IDs and Group IDs 237 8.12 Interpreter Files 242 8.13 system Function 246 8.14 Process Accounting 250 8.15 User Identification 256 8.16 Process Times 257 8.17 Summary 259 Chapter 9. Process Relationships 261 9.1 Introduction 261 9.2 Terminal Logins 261 9.3 Network Logins 266 9.4 Process Groups 269 9.5 Sessions 270 9.6 Controlling Terminal 272 9.7 tcgetpgrp, tcsetpgrp, and tcgetsid Functions 273 9.8 Job Control 274 9.9 Shell Execution of Programs 278 9.10 Orphaned Process Groups 282 9.11 FreeBSD Implementation 285 9.12 Summary 287 Chapter 10. Signals 289 10.1 Introduction 289 10.2 Signal Concepts 289 10.3 signal Function 298 10.4 Unreliable Signals 301 10.5 Interrupted System Calls 303 10.6 Reentrant Functions 305 10.7 s IGCLD Semantics 308 10.8 Reliable-Signal Terminology and Semantics 310 10.9 kill and raise Functions 311 10.10 alarm and pause Functions 313 10.11 Signal Sets 318 10.12 sigprocmask Function 320 10.13 s igpending Function 322 10.14 sigaction Function 324 10.15 sigsetjmp and siglongjmp Functions 329 10.16 s igsuspend Function 333 10.17 abort Function 340 10.18 sys t em Function 342 10.19 s I eep Function 347 10.20 Job-Control Signals 349 10.21 Additional Features 352 10.22 Summary 353 Chapter 11. Threads 355 11.1 Introduction 355 11.2 Thread Concepts 355 11.3 Thread Identification 356 11.4 Thread Creation 357 11.5 Thread Termination 360 11.6 Thread Synchronization 368 11.7 Summary 385 Chapter 12. Thread Control 387 12.1 Introduction 387 12.2 Thread Limits 387 12.3 Thread Attributes 388 12.4 Synchronization Attributes 393 12.5 Reentrancy 401 12.6 Thread-Specific Data 406 12.7 Cancel Options 410 12.8 Threads and Signals 413 12.9 Threads and fork 416 12.10 Threads and I/O 420 12.11 Summary 420 Chapter 13. Daemon Processes 423 13.1 Introduction 423 13.2 Daemon Characteristics 423 13.3 Coding Rules 425 13.4 Error Logging 428 13.5 Single-Instance Daemons 432 13.6 Daemon Conventions 434 13.7 Client-Server Model 439 13.8 Summary 439 Chapter 14. Advanced I/O 441 14.1 Introduction 441 14.2 Nonblocking I/O 441 14.3 Record Locking 444 14.4 STREAMS 460 14.5 I/O Multiplexing 472 14.5.1 select and pselect Functions 474 14.5.2 pol 1 Function 479 14.6 Asynchronous I/O 481 14.6.1 System V Asynchronous I/O 481 14.6.2 BSD Asynchronous I/O 482 14.7 readv and writev Functions 483 14.8 readn and writen Functions 485 14.9 Memory-Mapped I/O 487 14.10 Summary 492 Chapter 15. Interprocess Communication 495 15.1 Introduction 495 15.2 Pipes 496 15.3 popen and pclose Functions 503 15.4 Cop rocesses 510 15.5 FIFOs 514 15.6 XSI IPC 518 15.6.1 Identifiers and Keys 518 15.6.2 Permission Structure 520 15.6.3 Configuration Limits 521 15.6.4 Advantages and Disadvantages 521 15.7 Message Queues 522 15.8 Semaphores 527 15.9 Shared Memory 533 15.10 Client-Server Properties 541 15.11 Summary 543 Chapter 16. Network IPC: Sockets 545 16.1 Introduction 545 16.2 Socket Descriptors 546 16.3 Addressing 549 16.3.1 Byte Ordering 549 16.3.2 Address Formats 551 16.3.3 Address Lookup 553 16.3.4 Associating Addresses with Sockets 560 16.4 Connection Establishment 561 16.5 Data Transfer 565 16.6 Socket Options 579 16.7 Out-of-Band Data 581 16.8 Nonblocking and Asynchronous I/O 582 16.9 Summary 583 Chapter 17. Advanced IPC 585 17.1 Introduction 585 17.2 STREAMS-Based Pipes 585 17.2.1 Naming STREAMS Pipes 589 17.2.2 Unique Connections 590 17.3 UNIX Domain Sockets 594 17.3.1 Naming UNIX Domain Sockets 595 17.3.2 Unique Connections 597 17.4 Passing File Descriptors 601 17.4.1 Passing File Descriptors over STREAMS-Based Pipes 604 17.4.2 Passing File Descriptors over UNIX Domain Sockets 606 17.5 An Open Server, Version 1 615 17.6 An Open Server, Version 2 620 17.7 Summary 629 Chapter 18. Terminal I/O 631 18.1 Introduction 631 18.2 Overview 631 18.3 Special Input Characters 638 18.4 Getting and Setting Terminal Attributes 643 18.5 Terminal Option Flags 643 18.6 stty Command 651 18.7 Baud Rate Functions 652 18.8 Line Control Functions 653 18.9 Terminal Identification 654 18.10 Canonical Mode 660 18.11 Noncanonical Mode 663 18.12 Terminal Window Size 670 18.13 termcap, terminfo, and curses 672 18.14 Summary 673 Chapter 19. Pseudo Terminals 675 19.1 Introduction 675 19.2 Overview 675 19.3 Opening Pseudo-Terminal Devices 681 19.3.1 STREAMS-Based Pseudo Terminals 683 19.3.2 BSD-Based Pseudo Terminals 686 19.3.3 Linux-Based Pseudo Terminals 689 19.4 pty fork Function 691 19.5 pty Program 694 19.6 Using the pty Program 698 19.7 Advanced Features 705 19.8 Summary 706 Chapter 20. A Database Library 709 20.1 Introduction 709 20.2 History 709 20.3 The Library 710 20.4 Implementation Overview 712 20.5 Centralized or Decentralized? 716 20.6 Concurrency 718 20.7 Building the Library 719 20.8 Source Code 719 20.9 Performance 747 20.10 Summary 752 Chapter 21. Communicating with a Network Printer 753 21.1 Introduction 753 21.2 The Internet Printing Protocol 753 21.3 The Hypertext Transfer Protocol 756 21.4 Printer Spooling 757 21.5 Source Code 758 21.6 Summary 805 Appendix A. Function Prototypes 807 Appendix B. Miscellaneous Source Code 843 B.1 Our Header File 843 B.2 Standard Error Routines 846 Appendix C. Solutions to Selected Exercises 853 Bibliography 885 Index 891
【展开】
内容简介
本书是被誉为UNIX编程“圣经”的Advanced Programming in the UNIX Environment一书的更新版。在本书第一版出版后的十几年中,UNIX行业已经有了巨大的变化,特别是影响UNIX编程接口的有关标准变化很大。本书在保持了前一版的风格的基础上,根据最新的标准对内容进行了修订和增补,反映了最新的技术发展。书中除了介绍UNIX文件和目录、标准I/O库、系统数据文件和信息、进程环境、进程控制、进程关系、信号、线程、线程控制、守护进程、各种I/O、进程间通信、网络IPC、伪终端等方面的内容,还在此基础上介绍了多个应用示例,包括如何创建数据库函数库以及如何与网络打印机通信等。此外还在附录中给出了函数原型和部分习题的答案。 本书内容权威,概念清晰,阐述精辟,对于所有层次UNIX程序员都是一本不可或缺的参考书。
【展开】
下载说明

1、追日是作者栎年创作的原创作品,下载链接均为网友上传的的网盘链接!

2、相识电子书提供优质免费的txt、pdf等下载链接,所有电子书均为完整版!

下载链接
热门评论
  • 猪是念着倒我的评论
    没有目录,但还是很感谢分享这本书。 对电子书《UNIX环境高级编程(第3版)-edac.pdf》的评论via@读远网页链接
  • 王者伟业的评论
    从七月份开始,到今天,一本笔记本记完了。包含了《unix环境高级编程》从第一章到第十二章的学习笔记。书和笔记都已经被自己翻的脏兮兮的了[哈哈]
  • 小新一往无前的评论
    按计划,UNIX环境高级编程,鸟哥的LINUX私房菜,Python程序设计,疯狂安卓讲义,编译原理 第二版都可以在年底时候看完。C++ PRIMER PLUS,算法设计与分析,可以在开课前结束。现在没有考研的束缚,终于可以敞开了学专业知识,努力追赶大牛。不管是事业上的梦想还是人生上的梦想,都近了。我等了太久……
  • 光之烙印koon的评论
    我想读《UNIX环境高级编程》: 网页链接 来自@豆瓣App
  • 龙三蠹的评论
    昨夜梦至世界末日,天地崩裂,湖海干涸,满街的人豕突狼奔,我心脏狂跳,旁边有一个消防员模样的人冲我大吼:“只能带必需品走,书一类的东西tmd绝逼不能超过一本”,最后我犹豫良久,带了rechard steven的《unix环境下的高级编程》,是十几年前刚上班时用的书。这说明我骨子里是个死技术宅?
  • 人民邮电出版社-信息技术分社的评论
    【今日推荐】《UNIX环境高级编程》(第3版)是被誉为UNIX编程“圣经”的Advanced Programming in the UNIX Environment一书的第3版。已经第四印啦!亚马逊评论:原来看第二版没有太大感觉,最近从图书馆借来第三版对比这读了下,发现翻译比第二版要强。更改的内容也不少。我觉得有必要入手。[微笑]
  • Howell_Tan的评论
    unix高级环境编程看起来好费劲,还是要先看os的基础书啊
  • 伯乐头条的评论
    《Unix 环境高级编程 笔记》 (分享自 @伯乐头条)《Unix 环境高级...
  • 苏西财人的评论
    乘着新年把unix环境高级编程好好研究一遍,空闲机会难得。技术根本还是不能丢,出来也能吹吹牛逼啊。