注册 | 登录读书好,好读书,读好书!
读书网-DuShu.com
当前位置: 首页出版图书科学技术计算机/网络操作系统UNIXUNIX环境高级编程

UNIX环境高级编程

UNIX环境高级编程

定 价:¥99.00

作 者: (美)W.R.著
出版社: 人民邮电出版社
丛编项: 图灵原版计算机科学系列
标 签: UNIX

ISBN: 9787115144843 出版时间: 2006-01-01 包装: 胶版纸
开本: 小16开 页数: 948 字数:  

内容简介

  内容提要本书是被誉为UNIX编程"圣经"的Advanced Programming in the UNIX Environment一书的更新版。在本书第1版出版后的十几年中,UNIX行业已经有了巨大的变化,特别是影响UNIX编程接口的有关标准变化很大。本书在保持了前一版的风格的基础上,根据最新的标准对内容进行了修订和增补,反映了最新的技术发展。书中除了介绍UNIX文件和、标准I/O库、系统数据文件和信息、进程环境、进程控制、进程关系、信号、线程、线程控制、守护进程、各种I/O、进程间通信、网络IPC、伪终端等方面的内容,还在此基础上介绍了多个应用示例,包括如何创建数据库函数库以及如何与网络打印机通信等。此外,还在附录中给出了函数原型和部分习题的答案。本书内容权威,概念清晰,阐述精辟,对于所有层次UNIX程序员都是一本不可或缺的参考书。 ContentsChapter 1. UNIX System Overview 11.1 Introduction 11.2 UNIX Architecture 11.3 Logging In 21.4 Files and Directories 41.5 Input and Output 81.6 Programs and Processes 101.7 Error Handling 141.8 User Identification 161.9 Signals 181.10 Time Values 201.11 System Calls and Library Functions 211.12 Summary 23Chapter 2. UNIX Standardization and Implementations 252.1 Introduction 252.2 UNIX Standardization 252.2.1ISO C 252.2.2IEEE POSIX 262.2.3The Single UNIX Specification 292.2.4FIPS 332.3 UNIX System Implementations 332.3.1UNIX System V Release 4 332.3.24.4BSD 342.3.3FreeBSD 352.3.4Linux 352.3.5Mac OS X 352.3.6Solaris 352.3.7Other UNIX Systems 362.4 Relationship of Standards and Implementations 362.5 Limits 362.5.1ISO C Limits 382.5.2POSlX Limits 382.5.3XSl Limits 402.5.4sysconf, pathconf, and fpathconf Functions 412.5.5Indeterminate Runtime Limits 482.6 Options 522.7 Feature Test Macros 552.8 Primitive System Data Types 562.9 Conflicts Between Standards 562.10 Summary 58Chapter 3. File I/0 593.1 Introduction 593.2 File Descriptors 593.3 open Function 603.4 creat Function 623.5 close Function 633.6 1 seek Function 633.7 read Function 673.8 write Function 683.9 I/O Efficiency 683.10 File Sharing 703.11 Atomic Operations 743.12 dup and dup2 Functions 763.13 sync, fsync, and fdatasync Functions 773.14 fcnt 1 Function 783.15 ioct 1 Function 833.16 /dev/fd 843.17 Summary 85Chapter 4. Files and Directories 874.1 Introduction 874.2 stat, fstat, and lstat Functions 874.3 File Types 884.4 Set-User-ID and Set-Group-ID 914.5 File Access Permissions 924.6 Ownership of New Files and Directories 954.7 access Function 954.8 umask Function 974.9 chmod and f chmod Functions 994.10 StickyBit 1014.11 chown, fchown, and lchown Functions 1024.12 File Size 1034.13 File Truncation 1054.14 File Systems 1054.15 link, unlink, remove, and rename Functions 1084.16 Symbolic Links 1124.17 syml ink and readlink Functions 1154.18 File Times 1154.19 ut ime Function 1164.20 mkdir and rmdir Functions 1194.21 Reading Directories 1204.22 chdir, fchdir, and getcwd Functions 1254.23 Device Special Files 1274.24 Summary of File Access Permission Bits 1304.25 Summary 130Chapter 5. Standard I/O Library 1335.1 Introduction 1335.2 Streams and FILE Objects 1335.3 Standard Input, Standard Output, and Standard Error 1355.4 Buffering 1355.5 Opening a Stream 1385.6 Reading and Writing a Stream 1405.7 Line-at-a-Time I/O 1425.8 Standard I/O Efficiency 1435.9 Binary I/O 1455.10 Positioning a Stream 1475.11 Formatted I/O 1495.12 Implementation Details 1535.13 Temporary Files 1555.14 Alternatives to Standard I/O 1595.15 Summary 159Chapter 6. System Data Files and Information 1616.1 Introduction 1616.2 Password File 1616.3 Shadow Passwords 1656.4 Group File 1666.5 Supplementary Group IDs 1676.6 Implementation Differences 1696.7 Other Data Files 1696.8 Login Accounting 1706.9 System Identification 1716.10 Time and Date Routines 1736.11 Summary 177Chapter 7. Process Environment 1797.1 Introduction 1797.2 main Function 1797.3 Process Termination 1807.4 Command-Line Arguments 1857.5 Environment List 1857.6 Memory Layout of a C Program 1867.7 Shared Libraries 1887.8 Memory Allocation 1897.9 Environment Variables 1927.10 set j mp and longj mp Functions 1957.11 getrlimit and setrlimit Functions 2027.12 Summary 206Chapter 8. Process Control 2098.1 Introduction 2098.2 Process Identifiers 2098.3 fork Function 2118.4 vfork Function 2168.5 exit Functions 2188.6 wait and waitpid Functions 2208.7 waitid Function 2268.8 wait3 and wait4 Functions 2278.9 Race Conditions 2278.10 exec Functions 2318.11 Changing User IDs and Group IDs 2378.12 Interpreter Files 2428.13 system Function 2468.14 Process Accounting 2508.15 User Identification 2568.16 Process Times 2578.17 Summary 259Chapter 9. Process Relationships 2619.1 Introduction 2619.2 Terminal Logins 2619.3 Network Logins 2669.4 Process Groups 2699.5 Sessions 2709.6 Controlling Terminal 2729.7 tcgetpgrp, tcsetpgrp, and tcgetsid Functions 2739.8 Job Control 2749.9 Shell Execution of Programs 2789.10 Orphaned Process Groups 2829.11 FreeBSD Implementation 2859.12 Summary 287Chapter 10.Signals 28910.1 Introduction 28910.2 Signal Concepts 28910.3 signal Function 29810.4 Unreliable Signals 30110.5 Interrupted System Calls 30310.6 Reentrant Functions 30510.7 s IGCLD Semantics 30810.8 Reliable-Signal Terminology and Semantics 31010.9 kill and raise Functions 31110.10 alarm and pause Functions 31310.11 Signal Sets 31810.12 sigprocmask Function 32010.13 s igpending Function 32210.14 sigaction Function 32410.15 sigsetjmp and siglongjmp Functions 32910.16 s igsuspend Function 33310.17 abort Function 34010.18 sys t em Function 34210.19 s I eep Function 34710.20 Job-Control Signals 34910.21 Additional Features 35210.22 Summary 353Chapter 11.Threads 35511.1 Introduction 35511.2 Thread Concepts 35511.3 Thread Identification 35611.4 Thread Creation 35711.5 Thread Termination 36011.6 Thread Synchronization 36811.7 Summary 385Chapter 12.Thread Control 38712.1 Introduction 38712.2 Thread Limits 38712.3 Thread Attributes 38812.4 Synchronization Attributes 39312.5 Reentrancy 40112.6 Thread-Specific Data 40612.7 Cancel Options 41012.8 Threads and Signals 41312.9 Threads and fork 41612.10 Threads and I/O 42012.11 Summary 420Chapter 13.Daemon Processes 42313.1 Introduction 42313.2 Daemon Characteristics 42313.3 Coding Rules 42513.4 Error Logging 42813.5 Single-Instance Daemons 43213.6 Daemon Conventions 43413.7 Client-Server Model 43913.8 Summary 439Chapter 14.Advanced I/O44114.1 Introduction 44114.2 Nonblocking I/O 44114.3 Record Locking 44414.4 STREAMS 46014.5 I/O Multiplexing 47214.5.1 select and pselect Functions 47414.5.2 pol 1 Function 47914.6 Asynchronous I/O 48114.6.1 System V Asynchronous I/O 48114.6.2 BSD Asynchronous I/O 48214.7 readv and writev Functions 48314.8 readn and writen Functions 48514.9 Memory-Mapped I/O 48714.10 Summary 492Chapter 15.Interprocess Communication 49515.1 Introduction 49515.2 Pipes 49615.3 popen and pclose Functions 50315.4 Cop rocesses 51015.5 FIFOs 51415.6 XSI IPC 51815.6.1 Identifiers and Keys 51815.6.2 Permission Structure 52015.6.3 Configuration Limits 52115.6.4 Advantages and Disadvantages 52115.7 Message Queues 52215.8 Semaphores 52715.9 Shared Memory 53315.10 Client-Server Properties 54115.11 Summary 543Chapter 16.Network IPC: Sockets 54516.1 Introduction 54516.2 Socket Descriptors 54616.3 Addressing 54916.3.1 Byte Ordering 54916.3.2 Address Formats 55116.3.3 Address Lookup 55316.3.4 Associating Addresses with Sockets 56016.4 Connection Establishment 56116.5 Data Transfer 56516.6 Socket Options 57916.7 Out-of-Band Data 58116.8 Nonblocking and Asynchronous I/O 58216.9 Summary 583Chapter 17.Advanced IPC 58517.1 Introduction 58517.2 STREAMS-Based Pipes 58517.2.1 Naming STREAMS Pipes 58917.2.2 Unique Connections 59017.3 UNIX Domain Sockets 59417.3.1 Naming UNIX Domain Sockets 59517.3.2 Unique Connections 59717.4 Passing File Descriptors 60117.4.1 Passing File Descriptors over STREAMS-Based Pipes 60417.4.2 Passing File Descriptors over UNIX Domain Sockets 60617.5 An Open Server, Version 1 61517.6 An Open Server, Version 2 62017.7 Summary 629Chapter 18.Terminal I/O 63118.1 Introduction 63118.2 Overview 63118.3 Special Input Characters 63818.4 Getting and Setting Terminal Attributes 64318.5 Terminal Option Flags 64318.6 stty Command 65118.7 Baud Rate Functions 65218.8 Line Control Functions 65318.9 Terminal Identification 65418.10 Canonical Mode 66018.11 Noncanonical Mode 66318.12 Terminal Window Size 67018.13 termcap, terminfo, and curses 67218.14 Summary 673Chapter 19.Pseudo Terminals 67519.1 Introduction 67519.2 Overview 67519.3 Opening Pseudo-Terminal Devices 68119.3.1 STREAMS-Based Pseudo Terminals 68319.3.2 BSD-Based Pseudo Terminals 68619.3.3 Linux-Based Pseudo Terminals 68919.4 pty fork Function 69119.5 pty Program 69419.6 Using the pty Program 69819.7 Advanced Features 70519.8 Summary 706Chapter 20.A Database Library 70920.1 Introduction 70920.2 History 70920.3 The Library 71020.4 Implementation Overview 71220.5 Centralized or Decentralized? 71620.6 Concurrency 71820.7 Building the Library 71920.8 Source Code 71920.9 Performance 74720.10 Summary 752Chapter 21.Communicating with a Network Printer 75321.1 Introduction 75321.2 The Internet Printing Protocol 75321.3 The Hypertext Transfer Protocol 75621.4 Printer Spooling 75721.5 Source Code 75821.6 Summary 805Appendix A.Function Prototypes 807Appendix B.Miscellaneous Source Code 843B.1 Our Header File 843B.2 Standard Error Routines 846Appendix C.Solutions to Selected Exercises 853Bibliography 885Index 891

作者简介

  作者:W.RichardStevens国际知名的Unix和网络专家,《TCP/IP详解》(三卷本)作者W.RichardStevens(1951-1999),是国际知名的Unix和网络专家;受人尊敬的计算机图书作家;同时他还是广受欢迎的教师和顾问。Stevens先生1951年生于赞比亚,他的家庭曾多次搬迁,最终定居于南非。早年,他就读于美国弗吉尼亚州的费什本军事学校,后获得密歇根大学学士、亚利桑那大学系统工程硕士和博士学位。他曾就职于基特峰国家天文台,从事计算机编程;还曾在康涅狄格州纽黑文市的健康系统国际公司任主管计算机服务的副总裁。Stevens先生不幸病逝于1999年9月1日,他的离去是计算机界的巨大损失。UNIX环境高级编程(第2版)>>更多作品

图书目录

Foreword.
Preface.
Preface to the First Edition.
1. UNIX System Overview.
    Introduction.
    UNIX Architecture.
    Logging In.
    Files and Directories.
    Input and Output.
    Programs and Processes.
    Error Handling.
    User Identification.
    Signals.
    Time Values.
    System Calls and Library Functions.
    Summary.
2. UNIX Standardization and Implementations.
    Introduction.
    UNIX Standardization.
    UNIX System Implementations.
    Relationship of Standards and Implementations.
    Limits.
    Options.
    Feature Test Macros.
    Primitive System Data Types.
    Conflicts Between Standards.
    Summary.
3. File I/O.
    Introduction.
    File Descriptors.
    open Function.
    creat Function.
    closeFunction.
    lseek Function.
    read Function.
    write Function.
    I/O Efficiency.
    File Sharing.
    Atomic Operations.
    dup and dup2 Functions.
    sync, fsync, and fdatasync Functions.
    fcntl Function.
    ioctl Function.
    /dev/fd.
    Summary.
4. Files and Directories.
    Introduction.
    stat, fstat, and lstat Functions.
    File Types.
    Set-User-ID and Set-Group-ID.
    File Access Per missions.
    Ownership of New Files and Directories.
    access Function.
    umask Function.
    chmodand fchmod Functions.
    Sticky Bit.
    chown, fchown, and lchown Functions.
    File Size.
    File Truncation.
    File Systems.
    link, unlink, remove, and rename Functions.
    Symbolic Links.
    symlinkand readlink Functions.
    File Times.
    utime Function.
    mkdirand rmdir Functions.
    Reading Director ies.
    chdir, fchdir, and getcwd Functions.
    Device Special Files.
    Summary of File Access Per mission Bits.
    Summary.
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.
6. System Data Files and Information.
    Introduction.
    Password File.
    Shadow Passwords.
    Group File.
    Supplementary Group Ids.
    Implementation Differences.
    Other Data Files.
    Login Accounting.
    System Identification.
    Time and Date Routines.
    Summary.
7. Process Environment.
    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.
8. Process Control.
    Introduction.
    Process Identifiers.
    fork Function.
    vfork Function.
    exit Functions.
    waitand waitpid Functions.
    waitid Function.
    wait3and wait4Functions.
    Race Conditions.
    exec Functions.
    Changing User IDs and Group IDs.
    Interpreter Files.
    system Function.
    Process Accounting.
    User Identification.
    Process Times.
    Summary.
9. Process Relationships.
    Introduction.
    Terminal Logins.
    Network Logins.
    Process Groups.
    Sessions.
    Controlling Terminal.
    tcgetpgrp, tcsetpgrp, and tcgetsid Functions.
    Job Control.
    Shell Execution of Programs.
    Orphaned Process Groups.
    FreeBSD Implementation.
    Summary.
10. Signals.
    Introduction.
    Signal Concepts.
    signal Function.
    Unreliable Signals.
    Interrupted System Calls.
    Reentrant Functions.
    SIGCLD Semantics.
    Reliable-Signal Terminology and Semantics.
    killand raise Functions.
    alarmand 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.
11. Threads.
    Introduction.
    Thread Concepts.
    Thread Identification.
    Thread Creation.
    Thread Termination.
    Thread Synchronization.
    Summary.
12. Thread Control.
    Introduction.
    Thread Limits.
    hread Attributes.
    Synchronization Attributes.
    Reentrancy.
    Thread-Specific Data.
    Cancel Options.
    Threads and Signals.
    Threads and fork.
    Threads and I/O.
    Summary.
13. Daemon Processes.
    Introduction.
    Daemon Characteristics.
    Coding Rules.
    Error Logging.
    Single-Instance Daemons.
    Daemon Conventions.
    Client-Server Model.
    Summary.
14. Advanced I/O.
    Introduction.
    Nonblocking I/O.
    Record Locking.
    STREAMS.
    I/O Multiplexing.
    2 poll Function.
    Asynchronous I/O.
    readv and writev Functions.
    readn and written Functions.
    Memory-Mapped I/O.
    Summary.
15. Interprocess Communication.
    Introduction.
    Pipes.
    popen and pclose Functions.
    Coprocesses.
    FIFOs.
    XSI IPC.
    Message Queues.
    Semaphores.
    Shared Memory.
    Client-Server Properties.
    Summary.
16. Network IPC: Sockets.
    Introduction.
    Socket Descriptors.
    Addressing.
    Connection Establishment.
    Data Transfer.
    Socket Options.
     Out-of-Band Data.
    Nonblocking and Asynchronous I/O.
    Summary.
17 Advanced IPC.
    Introduction.
    STREAMS-Based Pipes.
    Unique Connections.
    Passing File Descriptors.
     An Open Server, Version 1.
    An Open Server, Version 2.
    Summary.
18. 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.
19. Pseudo Terminals.
    Introduction.
    Overview.
    Opening Pseudo-Terminal Devices.
    pty_fork Function.
    pty Program.
    Using the pty Program.
    Advanced Features.
    Summary.
20. A Database Library.
    Introduction.
    History.
    The Library.
    Implementation Overview.
    Centralized or Decentralized?
    Concurrency.
    Building the Library.
    Source Code.
    Performance.
    Summary.
21. Communicating with a Network Printer.
    Introduction.
    The Inter net Printing Protocol.
    The Hypertext Transfer Protocol.
    Printer Spooling.
    Source Code.
    Summary.
Appendix A. Function Prototypes.
Appendix B. Miscellaneous Source Code.
    Our Header File.
    Standard Error Routines.
Appendix C. Solutions to Selected Exercises.
Bibliography.
Index.

本目录推荐