Advanced Programming in the UNIX Environment
Häftad, Engelska, 2013
699 kr
Practical, in-depth knowledge of the system programming interfaces that drive the UNIX and Linux kernels
Building on W. Rich Stevens’ pioneering work, this third edition of the classic was updated by Steve Rago, a colleague of Stevens, to reflect technical advances and best practices aligning with Version 4 of the Single UNIX Specification.
This edition covers more than seventy interfaces including:
- POSIX asynchronous I/O
- Spin locks
- Barriers
- POSIX semaphores
Steve carefully retains the spirit and approach that have made this book so valuable, starting with files, directories, and processes, carefully laying the groundwork for more advanced techniques, such as signal handling and terminal I/O. And he thoroughly covers threads and multithreaded programming, and socket-based IPC.
Filled with examples, case-studies, and access to thousands of lines of downloadable code, Advanced Programming in the UNIX® Environment has helped generations of programmers write code with exceptional power, performance, and reliability.
Produktinformation
- Utgivningsdatum2013-05-30
- Mått234 x 56 x 194 mm
- Vikt2 100 g
- FormatHäftad
- SpråkEngelska
- SerieAddison-Wesley Professional Computing Series
- Antal sidor1 032
- Upplaga3
- FörlagPearson Education
- ISBN9780321637734
Tillhör följande kategorier
The late W. Richard Stevens was the acclaimed author of UNIX® Network Programming, Volumes 1 and 2, widely recognized as the classic texts in UNIX networking; TCP/IP Illustrated, Volumes 1-3; and the first edition of this book.Stephen A. Rago is the author of UNIX® System V Network Programming (Addison-Wesley, 1993). Rago was one of the Bell Laboratories developers who built UNIX System V Release 4. He served as a technical reviewer for the first edition of Advanced Programming in the UNIX® Environment. Rago currently works as a research staff member in the Storage Systems Group at NEC Laboratories America.
- Foreword to the Second Edition xixPreface xxiPreface to the Second Edition xxvPreface to the First Edition xxixChapter 1: UNIX System Overview 11.1 Introduction 1 1.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 Librar y Functions 211.12 Summary 23Chapter 2: UNIX Standardization and Implementations 252.1 Introduction 25 2.2 UNIX Standardization 252.3 UNIX System Implementations 332.4 Relationship of Standards and Implementations 362.5 Limits 362.6 Options 532.7 Feature Test Macros 572.8 Primitive System Data Types 582.9 Differences Between Standards 582.10 Summary 60Chapter 3: File I/O 613.1 Introduction 61 3.2 File Descr iptors 613.3 open and openat Functions 623.4 creat Function 663.5 close Function 663.6 lseek Function 663.7 read Function 713.8 write Function 723.9 I/O Efficiency 723.10 File Shar ing 743.11 Atomic Operations 773.12 dup and dup2 Functions 793.13 sync, fsync, and fdatasync Functions 813.14 fcntl Function 823.15 ioctl Function 873.16 /dev/fd 883.17 Summary 90Chapter 4: Files and Directories 934.1 Introduction 93 4.2 stat, fstat, fstatat, and lstat Functions 934.3 File Types 954.4 Set-User-ID and Set-Group-ID 984.5 File Access Per missions 994.6 Ownership of New Files and Directories 1014.7 access and faccessat Functions 1024.8 umask Function 1044.9 chmod, fchmod, and fchmodat Functions 1064.10 Sticky Bit 1084.11 chown, fchown, fchownat, and lchown Functions 1094.12 File Size 1114.13 File Tr uncation 1124.14 File Systems 1134.15 link, linkat, unlink, unlinkat, and remove Functions 1164.16 rename and renameat Functions 1194.17 Symbolic Links 1204.18 Creating and Reading Symbolic Links 1234.19 File Times 1244.20 futimens, utimensat, and utimes Functions 1264.21 mkdir, mkdirat, and rmdir Functions 1294.22 Reading Director ies 1304.23 chdir, fchdir, and getcwd Functions 1354.24 Device Special Files 1374.25 Summary of File Access Per mission Bits 1404.26 Summary 140Chapter 5: Standard I/O Library 1435.1 Introduction 143 5.2 Streams and FILE Objects 1435.3 Standard Input, Standard Output, and Standard Error 1455.4 Buffer ing 1455.5 Opening a Stream 1485.6 Reading and Writing a Stream 1505.7 Line-at-a-Time I/O 1525.8 Standard I/O Efficiency 1535.9 Binary I/O 1565.10 Positioning a Stream 1575.11 For matted I/O 1595.12 Implementation Details 1645.13 Temporar y Files 1675.14 Memory Streams 1715.15 Alternatives to Standard I/O 1745.16 Summary 175Chapter 6: System Data Files and Information 1776.1 Introduction 177 6.2 Password File 1776.3 Shadow Passwords 1816.4 Group File 1826.5 Supplementary Group IDs 1836.6 Implementation Differences 1846.7 Other Data Files 1856.8 Login Accounting 1866.9 System Identification 1876.10 Time and Date Routines 1896.11 Summary 196Chapter 7: Process Environment 1977.1 Introduction 197 7.2 main Function 1977.3 Process Termination 1987.4 Command-Line Arguments 2037.5 Environment List 2037.6 Memory Lay out of a C Program 2047.7 Shared Librar ies 2067.8 Memory Allocation 2077.9 Environment Var iables 2107.10 setjmp and longjmp Functions 2137.11 getrlimit and setrlimit Functions 2207.12 Summary 225Chapter 8: Process Control 2278.1 Introduction 227 8.2 Process Identifiers 2278.3 fork Function 2298.4 vfork Function 2348.5 exit Functions 2368.6 wait and waitpid Functions 2388.7 waitid Function 2448.8 wait3 and wait4 Functions 2458.9 Race Conditions 2458.10 exec Functions 2498.11 Changing User IDs and Group IDs 2558.12 Interpreter Files 2608.13 system Function 2648.14 Process Accounting 2698.15 User Identification 2758.16 Process Scheduling 2768.17 Process Times 2808.18 Summary 282Chapter 9: Process Relationships 2859.1 Introduction 285 9.2 Ter minal Logins 2859.3 Networ k Logins 2909.4 Process Groups 2939.5 Sessions 2959.6 Controlling Terminal 2969.7 tcgetpgrp, tcsetpgrp, and tcgetsid Functions 2989.8 Job Control 2999.9 Shell Execution of Programs 3039.10 Orphaned Process Groups 3079.11 FreeBSD Implementation 3109.12 Summary 312Chapter 10: Signals 31310.1 Introduction 313 10.2 Signal Concepts 31310.3 signal Function 32310.4 Unreliable Signals 32610.5 Interrupted System Calls 32710.6 Reentrant Functions 33010.7 SIGCLD Semantics 33210.8 Reliable-Signal Ter minology and Semantics 33510.9 kill and raise Functions 33610.10 alarm and pause Functions 33810.11 Signal Sets 34410.12 sigprocmask Function 34610.13 sigpending Function 34710.14 sigaction Function 34910.15 sigsetjmp and siglongjmp Functions 35510.16 sigsuspend Function 35910.17 abort Function 36510.18 system Function 36710.19 sleep, nanosleep, and clock_nanosleep Functions 37310.20 sigqueue Function 37610.21 Job-Control Signals 37710.22 Signal Names and Numbers 37910.23 Summary 381Chapter 11: Threads 38311.1 Introduction 383 11.2 Thread Concepts 38311.3 Thread Identification 38411.4 Thread Creation 38511.5 Thread Termination 38811.6 Thread Synchronization 39711.7 Summary 422Chapter 12: Thread Control 42512.1 Introduction 425 12.2 Thread Limits 42512.3 Thread Attr ibutes 42612.4 Synchronization Attr ibutes 43012.5 Reentrancy 44212.6 Thread-Specific Data 44612.7 Cancel Options 45112.8 Threads and Signals 45312.9 Threads and fork 45712.10 Threads and I/O 46112.11 Summary 462Chapter 13: Daemon Processes 46313.1 Introduction 463 13.2 Daemon Character istics 46313.3 Coding Rules 46613.4 Error Logging 46913.5 Single-Instance Daemons 47313.6 Daemon Conventions 47413.7 Client–Server Model 47913.8 Summary 480Chapter 14: Advanced I/O 48114.1 Introduction 481 14.2 Nonblocking I/O 48114.3 Record Locking 48514.4 I/O Multiplexing 50014.5 Asynchronous I/O 50914.6 readv and writev Functions 52114.7 readn and writen Functions 52314.8 Memory-Mapped I/O 52514.9 Summary 531Chapter 15: Interprocess Communication 53315.1 Introduction 533 15.2 Pipes 53415.3 popen and pclose Functions 54115.4 Coprocesses 54815.5 FIFOs 55215.6 XSI IPC 55615.7 Message Queues 56115.8 Semaphores 56515.9 Shared Memor y 57115.10 POSIX Semaphores 57915.11 Client–Server Proper ties 58515.12 Summary 587Chapter 16: Network IPC: Sockets 58916.1 Introduction 589 16.2 Socket Descr iptors 59016.3 Addressing 59316.4 Connection Establishment 60516.5 Data Tr ansfer 61016.6 Socket Options 62316.7 Out-of-Band Data 62616.8 Nonblocking and Asynchronous I/O 62716.9 Summary 628Chapter 17: Advanced IPC 62917.1 Introduction 629 17.2 UNIX Domain Sockets 62917.3 Unique Connections 63517.4 Passing File Descriptors 64217.5 An Open Server, Version 1 65317.6 An Open Server, Version 2 65917.7 Summary 669Chapter 18: Terminal I/O 67118.1 Introduction 671 18.2 Over view 67118.3 Special Input Characters 67818.4 Getting and Setting Ter minal Attr ibutes 68318.5 Ter minal Option Flags 68318.6 stty Command 69118.7 Baud Rate Functions 69218.8 Line Control Functions 69318.9 Ter minal Identification 69418.10 Canonical Mode 70018.11 Noncanonical Mode 70318.12 Ter minal Window Size 71018.13 termcap, terminfo, and curses 71218.14 Summary 713Chapter 19: Pseudo Terminals 71519.1 Introduction 715 19.2 Over view 71519.3 Opening Pseudo-Ter minal Devices 72219.4 pty_fork Function 72619.5 pty Program 72919.6 Using the pty Program 73319.7 Advanced Features 74019.8 Summary 741Chapter 20: A Database Library 74320.1 Introduction 743 20.2 History 74320.3 The Librar y 74420.4 Implementation Over view 74620.5 Centralized or Decentralized? 75020.6 Concurrency 75220.7 Building the Librar y 75320.8 Source Code 75320.9 Perfor mance 78120.10 Summary 786Chapter 21: Communicating with a Network Printer 78921.1 Introduction 789 21.2 The Inter net Pr inting Protocol 78921.3 The Hyper text Transfer Protocol 79221.4 Printer Spooling 79321.5 Source Code 79521.6 Summary 843Appendix A: Function Prototypes 845Appendix B: Miscellaneous Source Code 895B.1 Our Header File 895B.2 Standard Error Routines 898Appendix C: Solutions to Selected Exercises 905Bibliography 947Index 955