Description
The new third edition of Advanced Programming in the UNIX® Environment supports today’s leading platforms, reflects new technical advances and best practices, and aligns with Version 4 of the Single UNIX Specification. This valuable tool begins with files, directories, and processes, carefully laying the groundwork for more advanced techniques, such as signal handling and terminal I/O then thoroughly covers threads and multithreaded programming, and socket-based IPC. This edition covers more than seventy new interfaces, including POSIX asynchronous I/O, spin locks, barriers, and POSIX semaphores. Students are given examples, including more than ten thousand lines of downloadable, ISO C source code. More than four hundred system calls and functions are demonstrated with concise, complete programs that clearly illustrate their usage, arguments, and return values. To tie together what they’ve learned, the book presents several chapter-length case studies, each reflecting contemporary environments.
Key Features
- W. Richard Stevens’ definitive, classic guide to UNIX® programming, now 100% updated for today’s leading systems and distributions!
- The #1 guide to UNIX/Linux programming since 1992: now updated to address newer versions of Red Hat, Solaris, FreeBSD, and Mac OS X, cover Ubuntu Linux, and reflect newer techniques and best practices
- Contains nearly 10,000 lines of code, all carefully tested on today’s most widely-used UNIX/Linux platforms
New to this Edition
- Updates of systems and distributions
- Includes RedHat 2.6x, Solaris 10, MacOS 10.5, FreeBSD 7.0, and Ubuntu Linux
Table of Contents
- Foreword to the Second Edition xix
- Preface xxi
- Preface to the Second Edition xxv
- Preface to the First Edition xxix
- Chapter 1: UNIX System Overview 1
- Introduction 1
- UNIX Architecture 1
- Logging In 2
- Files and Directories 4
- Input and Output 8
- Programs and Processes 10
- Error Handling 14
- User Identification 16
- Signals 18
- Time Values 20
- System Calls and Library Functions 21
- Summary 23
- Chapter 2: UNIX Standardization and Implementations 25
- Introduction 25
- UNIX Standardization 25
- UNIX System Implementations 33
- Relationship of Standards and Implementations 36
- Limits 36
- Options 53
- Feature Test Macros 57
- Primitive System Data Types 58
- Differences Between Standards 58
- Summary 60
- Chapter 3: File I/O 61
- Introduction 61
- File Descriptors 61
- open and openat Functions 62
- creat Function 66
- close Function 66
- lseek Function 66
- read Function 71
- write Function 72
- I/O Efficiency 72
- File Shar ing 74
- Atomic Operations 77
- dup and dup2 Functions 79
- sync, fsync, and fdatasync Functions 81
- fcntl Function 82
- ioctl Function 87
- /dev/fd 88
- Summary 90
- Chapter 4: Files and Directories 93
- Introduction 93
- stat, fstat, fstatat, and lstat Functions 93
- File Types 95
- Set-User-ID and Set-Group-ID 98
- File Access Per missions 99
- Ownership of New Files and Directories 101
- access and faccessat Functions 102
- umask Function 104
- chmod, fchmod, and fchmodat Functions 106
- Sticky Bit 108
- chown, fchown, fchownat, and lchown Functions 109
- File Size 111
- File Tr uncation 112
- File Systems 113
- link, linkat, unlink, unlinkat, and remove Functions 116
- rename and renameat Functions 119
- Symbolic Links 120
- Creating and Reading Symbolic Links 123
- File Times 124
- futimens, utimensat, and utimes Functions 126
- mkdir, mkdirat, and rmdir Functions 129
- Reading Director ies 130
- chdir, fchdir, and getcwd Functions 135
- Device Special Files 137
- Summary of File Access Per mission Bits 140
- Summary 140
- Chapter 5: Standard I/O Library 143
- Introduction 143
- Streams and FILE Objects 143
- Standard Input, Standard Output, and Standard Error 145
- Buffering 145
- Opening a Stream 148
- Reading and Writing a Stream 150
- Line-at-a-Time I/O 152
- Standard I/O Efficiency 153
- Binary I/O 156
- Positioning a Stream 157
- For matted I/O 159
- Implementation Details 164
- Temporary Files 167
- Memory Streams 171
- Alternatives to Standard I/O 174
- Summary 175
- Chapter 6: System Data Files and Information 177
- Introduction 177
- Password File 177
- Shadow Passwords 181
- Group File 182
- Supplementary Group IDs 183
- Implementation Differences 184
- Other Data Files 185
- Login Accounting 186
- System Identification 187
- Time and Date Routines 189
- Summary 196
- Chapter 7: Process Environment 197
- Introduction 197
- main Function 197
- Process Termination 198
- Command-Line Arguments 203
- Environment List 203
- Memory Lay out of a C Program 204
- Shared Libraries 206
- Memory Allocation 207
- Environment Var iables 210
- setjmp and longjmp Functions 213
- getrlimit and setrlimit Functions 220
- Summary 225
- Chapter 8: Process Control 227
- Introduction 227
- Process Identifiers 227
- fork Function 229
- vfork Function 234
- exit Functions 236
- wait and waitpid Functions 238
- waitid Function 244
- wait3 and wait4 Functions 245
- Race Conditions 245
- exec Functions 249
- Changing User IDs and Group IDs 255
- Interpreter Files 260
- system Function 264
- Process Accounting 269
- User Identification 275
- Process Scheduling 276
- Process Times 280
- Summary 282
- Chapter 9: Process Relationships 285
- Introduction 285
- Terminal Logins 285
- Network Logins 290
- Process Groups 293
- Sessions 295
- Controlling Terminal 296
- tcgetpgrp, tcsetpgrp, and tcgetsid Functions 298
- Job Control 299
- Shell Execution of Programs 303
- Orphaned Process Groups 307
- FreeBSD Implementation 310
- Summary 312
- Chapter 10: Signals 313
- Introduction 313
- Signal Concepts 313
- signal Function 323
- Unreliable Signals 326
- Interrupted System Calls 327
- Reentrant Functions 330
- SIGCLD Semantics 332
- Reliable-Signal Terminology and Semantics 335
- kill and raise Functions 336
- alarm and pause Functions 338
- Signal Sets 344
- sigprocmask Function 346
- sigpending Function 347
- sigaction Function 349
- sigsetjmp and siglongjmp Functions 355
- sigsuspend Function 359
- abort Function 365
- system Function 367
- sleep, nanosleep, and clock_nanosleep Functions 373
- sigqueue Function 376
- Job-Control Signals 377
- Signal Names and Numbers 379
- Summary 381
- Chapter 11: Threads 383
- Introduction 383
- Thread Concepts 383
- Thread Identification 384
- Thread Creation 385
- Thread Termination 388
- Thread Synchronization 397
- Summary 422
- Chapter 12: Thread Control 425
- Introduction 425
- Thread Limits 425
- Thread Attributes 426
- Synchronization Attributes 430
- Reentrancy 442
- Thread-Specific Data 446
- Cancel Options 451
- Threads and Signals 453
- Threads and fork 457
- Threads and I/O 461
- Summary 462
- Chapter 13: Daemon Processes 463
- Introduction 463
- Daemon Characteristics 463
- Coding Rules 466
- Error Logging 469
- Single-Instance Daemons 473
- Daemon Conventions 474
- Client–Server Model 479
- Summary 480
- Chapter 14: Advanced I/O 481
- Introduction 481
- Nonblocking I/O 481
- Record Locking 485
- I/O Multiplexing 500
- Asynchronous I/O 509
- readv and writev Functions 521
- readn and writen Functions 523
- Memory-Mapped I/O 525
- Summary 531
- Chapter 15: Interprocess Communication 533
- Introduction 533
- Pipes 534
- popen and pclose Functions 541
- Coprocesses 548
- FIFOs 552
- XSI IPC 556
- Message Queues 561
- Semaphores 565
- Shared Memory 571
- POSIX Semaphores 579
- Client–Server Proper ties 585
- Summary 587
- Chapter 16: Network IPC: Sockets 589
- Introduction 589
- Socket Descriptors 590
- Addressing 593
- Connection Establishment 605
- Data Transfer 610
- Socket Options 623
- Out-of-Band Data 626
- Nonblocking and Asynchronous I/O 627
- Summary 628
- Chapter 17: Advanced IPC 629
- Introduction 629
- UNIX Domain Sockets 629
- Unique Connections 635
- Passing File Descriptors 642
- An Open Server, Version 1 653
- An Open Server, Version 2 659
- Summary 669
- Chapter 18: Terminal I/O 671
- Introduction 671
- Over view 671
- Special Input Characters 678
- Getting and Setting Terminal Attributes 683
- Terminal Option Flags 683
- stty Command 691
- Baud Rate Functions 692
- Line Control Functions 693
- Terminal Identification 694
- Canonical Mode 700
- Noncanonical Mode 703
- Terminal Window Size 710
- termcap, terminfo, and curses 712
- Summary 713
- Chapter 19: Pseudo Terminals 715
- Introduction 715
- Over view 715
- Opening Pseudo-Terminal Devices 722
- pty_fork Function 726
- pty Program 729
- Using the pty Program 733
- Advanced Features 740
- Summary 741
- Chapter 20: A Database Library 743
- Introduction 743
- History 743
- The Library 744
- Implementation Over view 746
- Centralized or Decentralized? 750
- Concurrency 752
- Building the Library 753
- Source Code 753
- Performance 781
- Summary 786
- Chapter 21: Communicating with a Network Printer 789
- Introduction 789
- The Inter net Printing Protocol 789
- The Hyper text Transfer Protocol 792
- Printer Spooling 793
- Source Code 795
- Summary 843
- Appendix A: Function Prototypes 845
- Appendix B: Miscellaneous Source Code 895
- B.1 Our Header File 895
- B.2 Standard Error Routines 898
- Appendix C: Solutions to Selected Exercises 905
- Bibliography 947
- Index 955
Authors Biography
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.
Additional information
| Weight | 2.100 kg |
|---|
Only logged in customers who have purchased this product may leave a review.
Related Products













Reviews
There are no reviews yet.