Advanced Programming in the UNIX® Environment (3rd edition)
معرفی کتاب «Advanced Programming in the UNIX® Environment (3rd edition)» نوشتهٔ Junji Ito، translation، English adaptation، Yuji Oniki و Stevens, W. Richard & Rago, Stephen A.، منتشرشده توسط نشر Addison Wesley Publishing Company در سال 2013. این کتاب در 7 صفحه، فرمت pdf، زبان انگلیسی ارائه شده است.
Contents 11 Foreword to the Second Edition 21 Preface 23 Preface to the Second Edition 27 Preface to the First Edition 31 Chapter 1. UNIX System Overview 35 1.1 Introduction 35 1.2 UNIX Architecture 35 1.3 Logging In 36 1.4 Files and Directories 38 1.5 Input and Output 42 1.6 Programs and Processes 44 1.7 Error Handling 48 1.8 User Identification 50 1.9 Signals 52 1.10 Time Values 54 1.11 System Calls and Library Functions 55 1.12 Summary 57 Chapter 2. UNIX Standardization and Implementations 59 2.1 Introduction 59 2.2 UNIX Standardization 59 2.2.1 ISO C 59 2.2.2 IEEE POSIX 60 2.2.3 The Single UNIX Specification 64 2.2.4 FIPS 66 2.3 UNIX System Implementations 67 2.3.1 UNIX System V Release 4 67 2.3.2 4.4BSD 68 2.3.3 FreeBSD 68 2.3.4 Linux 69 2.3.5 Mac OS X 69 2.3.6 Solaris 69 2.3.7 Other UNIX Systems 69 2.4 Relationship of Standards and Implementations 70 2.5 Limits 70 2.5.1 ISO C Limits 71 2.5.2 POSIX Limits 72 2.5.3 XSI Limits 75 2.5.4 sysconf, pathconf, and fpathconf Functions 76 2.5.5 Indeterminate Runtime Limits 83 2.6 Options 87 2.7 Feature Test Macros 91 2.8 Primitive System Data Types 92 2.9 Differences Between Standards 92 2.10 Summary 94 Chapter 3. File I/O 95 3.1 Introduction 95 3.2 File Descriptors 95 3.3 open and openat Functions 96 3.4 creat Function 100 3.5 close Function 100 3.6 lseek Function 100 3.7 read Function 105 3.8 write Function 106 3.9 I/O Efficiency 106 3.10 File Sharing 108 3.11 Atomic Operations 111 3.12 dup and dup2 Functions 113 3.13 sync, fsync, and fdatasync Functions 115 3.14 fcntl Function 116 3.15 ioctl Function 121 3.16 /dev/fd 122 3.17 Summary 124 Chapter 4. Files and Directories 127 4.1 Introduction 127 4.2 stat, fstat, fstatat, and lstat Functions 127 4.3 File Types 129 4.4 Set-User-ID and Set-Group-ID 132 4.5 File Access Permissions 133 4.6 Ownership of New Files and Directories 135 4.7 access and faccessat Functions 136 4.8 umask Function 138 4.9 chmod, fchmod, and fchmodat Functions 140 4.10 Sticky Bit 142 4.11 chown, fchown, fchownat, and lchown Functions 143 4.12 File Size 145 4.13 File Truncation 146 4.14 File Systems 147 4.15 link, linkat, unlink, unlinkat, and remove Functions 150 4.16 rename and renameat Functions 153 4.17 Symbolic Links 154 4.18 Creating and Reading Symbolic Links 157 4.19 File Times 158 4.20 futimens, utimensat, and utimes Functions 160 4.21 mkdir, mkdirat, and rmdir Functions 163 4.22 Reading Directories 164 4.23 chdir, fchdir, and getcwd Functions 169 4.24 Device Special Files 171 4.25 Summary of File Access Per mission Bits 174 4.26 Summary 174 Chapter 5. Standard I/O Library 177 5.1 Introduction 177 5.2 Streams and FILE Objects 177 5.3 Standard Input, Standard Output, and Standard Error 179 5.4 Buffering 179 5.5 Opening a Stream 182 5.6 Reading and Writing a Stream 184 5.7 Line-at-a-Time I/O 186 5.8 Standard I/O Efficiency 187 5.9 Binary I/O 190 5.10 Positioning a Stream 191 5.11 Formatted I/O 193 5.12 Implementation Details 198 5.13 Temporary Files 201 5.14 Memory Streams 205 5.15 Alternatives to Standard I/O 208 5.16 Summary 209 Chapter 6. System Data Files and Information 211 6.1 Introduction 211 6.2 Password File 211 6.3 Shadow Passwords 215 6.4 Group File 216 6.5 Supplementary Group IDs 217 6.6 Implementation Differences 218 6.7 Other Data Files 219 6.8 Login Accounting 220 6.9 System Identification 221 6.10 Time and Date Routines 223 6.11 Summary 230 Chapter 7. Process Environment 231 7.1 Introduction 231 7.2 main Function 231 7.3 Process Termination 232 7.4 Command-Line Arguments 237 7.5 Environment List 237 7.6 Memory Lay out of a C Program 238 7.7 Shared Libraries 240 7.8 Memory Allocation 241 7.9 Environment Variables 244 7.10 setjmp and longjmp Functions 247 7.11 getrlimit and setrlimit Functions 254 7.12 Summary 259 Chapter 8. Process Control 261 8.1 Introduction 261 8.2 Process Identifiers 261 8.3 fork Function 263 8.4 vfork Function 268 8.5 exit Functions 270 8.6 wait and waitpid Functions 272 8.7 waitid Function 278 8.8 wait3 and wait4 Functions 279 8.9 Race Conditions 279 8.10 exec Functions 283 8.11 Changing User IDs and Group IDs 289 8.12 Interpreter Files 294 8.13 system Function 298 8.14 Process Accounting 303 8.15 User Identification 309 8.16 Process Scheduling 310 8.17 Process Times 314 8.18 Summary 316 Chapter 9. Process Relationships 319 9.1 Introduction 319 9.2 Terminal Logins 319 9.3 Network Logins 324 9.4 Process Groups 327 9.5 Sessions 329 9.6 Controlling Terminal 330 9.7 tcgetpgrp, tcsetpgrp, and tcgetsid Functions 332 9.8 Job Control 333 9.9 Shell Execution of Programs 337 9.10 Orphaned Process Groups 341 9.11 FreeBSD Implementation 344 9.12 Summary 346 Chapter 10. Signals 347 10.1 Introduction 347 10.2 Signal Concepts 347 10.3 signal Function 357 10.4 Unreliable Signals 360 10.5 Interrupted System Calls 361 10.6 Reentrant Functions 364 10.7 SIGCLD Semantics 366 10.8 Reliable-Signal Terminology and Semantics 369 10.9 kill and raise Functions 370 10.10 alarm and pause Functions 372 10.11 Signal Sets 378 10.12 sigprocmask Function 380 10.13 sigpending Function 381 10.14 sigaction Function 383 10.15 sigsetjmp and siglongjmp Functions 389 10.16 sigsuspend Function 393 10.17 abort Function 399 10.18 system Function 401 10.19 sleep, nanosleep, and clock_nanosleep Functions 407 10.20 sigqueue Function 410 10.21 Job-Control Signals 411 10.22 Signal Names and Numbers 413 10.23 Summary 415 Chapter 11. Threads 417 11.1 Introduction 417 11.2 Thread Concepts 417 11.3 Thread Identification 418 11.4 Thread Creation 419 11.5 Thread Termination 422 11.6 Thread Synchronization 431 11.6.1 Mutexes 433 11.6.2 Deadlock Avoidance 436 11.6.3 pthread_mutex_timedlock Function 441 11.6.4 Reader–Writer Locks 443 11.6.5 Reader–Writer Locking with Timeouts 447 11.6.6 Condition Variables 447 11.6.7 Spin Locks 451 11.6.8 Barriers 452 11.7 Summary 456 Chapter 12. Thread Control 459 12.1 Introduction 459 12.2 Thread Limits 459 12.3 Thread Attributes 460 12.4 Synchronization Attributes 464 12.4.1 Mutex Attributes 464 12.4.2 Reader–Writer Lock Attributes 473 12.4.3 Condition Variable Attributes 474 12.4.4 Barrier Attributes 475 12.5 Reentrancy 476 12.6 Thread-Specific Data 480 12.7 Cancel Options 485 12.8 Threads and Signals 487 12.9 Threads and fork 491 12.10 Threads and I/O 495 12.11 Summary 496 Chapter 13. Daemon Processes 497 13.1 Introduction 497 13.2 Daemon Characteristics 497 13.3 Coding Rules 500 13.4 Error Logging 503 13.5 Single-Instance Daemons 507 13.6 Daemon Conventions 508 13.7 Client–Server Model 513 13.8 Summary 514 Chapter 14. Advanced I/O 515 14.1 Introduction 515 14.2 Nonblocking I/O 515 14.3 Record Locking 519 14.4 I/O Multiplexing 534 14.4.1 select and pselect Functions 536 14.4.2 poll Function 540 14.5 Asynchronous I/O 543 14.5.1 System V Asynchronous I/O 544 14.5.2 BSD Asynchronous I/O 544 14.5.3 POSIX Asynchronous I/O 545 14.6 readv and writev Functions 555 14.7 readn and writen Functions 557 14.8 Memory-Mapped I/O 559 14.9 Summary 565 Chapter 15. Interprocess Communication 567 15.1 Introduction 567 15.2 Pipes 568 15.3 popen and pclose Functions 575 15.4 Coprocesses 582 15.5 FIFOs 586 15.6 XSI IPC 590 15.6.1 Identifiers and Keys 590 15.6.2 Permission Structure 592 15.6.3 Configuration Limits 593 15.6.4 Advantages and Disadvantages 593 15.7 Message Queues 595 15.8 Semaphores 599 15.9 Shared Memory 605 15.10 POSIX Semaphores 613 15.11 Client–Server Properties 619 15.12 Summary 621 Chapter 16. Network IPC: Sockets 623 16.1 Introduction 623 16.2 Socket Descriptors 624 16.3 Addressing 627 16.3.1 Byte Ordering 627 16.3.2 Address Formats 629 16.3.3 Address Lookup 631 16.3.4 Associating Addresses with Sockets 638 16.4 Connection Establishment 639 16.5 Data Transfer 644 16.6 Socket Options 657 16.7 Out-of-Band Data 660 16.8 Nonblocking and Asynchronous I/O 661 16.9 Summary 662 Chapter 17. Advanced IPC 663 17.1 Introduction 663 17.2 UNIX Domain Sockets 663 17.2.1 Naming UNIX Domain Sockets 668 17.3 Unique Connections 669 17.4 Passing File Descriptors 676 17.5 An Open Server, Version 1 687 17.6 An Open Server, Version 2 693 17.7 Summary 703 Chapter 18. Terminal I/O 705 18.1 Introduction 705 18.2 Overview 705 18.3 Special Input Characters 712 18.4 Getting and Setting Terminal Attributes 717 18.5 Terminal Option Flags 717 18.6 stty Command 725 18.7 Baud Rate Functions 726 18.8 Line Control Functions 727 18.9 Terminal Identification 728 18.10 Canonical Mode 734 18.11 Noncanonical Mode 737 18.12 Terminal Window Size 744 18.13 termcap, terminfo, and curses 746 18.14 Summary 747 Chapter 19. Pseudo Terminals 749 19.1 Introduction 749 19.2 Overview 749 19.3 Opening Pseudo-Terminal Devices 756 19.4 pty_fork Function 760 19.5 pty Program 763 19.6 Using the pty Program 767 19.7 Advanced Features 774 19.8 Summary 775 Chapter 20. A Database Library 777 20.1 Introduction 777 20.2 History 777 20.3 The Library 778 20.4 Implementation Overview 780 20.5 Centralized or Decentralized? 784 20.6 Concurrency 786 20.7 Building the Library 787 20.8 Source Code 787 20.9 Performance 815 20.10 Summary 820 Chapter 21. Communicating with a Network Printer 823 21.1 Introduction 823 21.2 The Internet Printing Protocol 823 21.3 The Hypertext Transfer Protocol 826 21.4 Printer Spooling 827 21.5 Source Code 829 21.6 Summary 877 Appendix A. Function Prototypes 879 Appendix B. Miscellaneous Source Code 929 B.1 Our Header File 929 B.2 Standard Error Routines 932 Appendix C. Solutions to Selected Exercises 939 Bibliography 981 Index 989 A 989 B 990 C 991 D 993 E 995 F 997 G 1000 H 1001 I 1002 J 1003 K 1003 L 1004 M 1005 N 1007 O 1007 P 1008 Q 1014 R 1014 S 1015 T 1023 U 1025 V 1026 W 1027 X 1028 Y 1028 Z 1028 623923 For more than twenty years, serious C programmers have relied on one book for practical, in-depth knowledge of the programming interfaces that drive the UNIX and Linux kernels: W. Richard Stevens’ Advanced Programming in the UNIX® Environment . Now, once again, Rich’s colleague Steve Rago has thoroughly updated this classic work. The new third edition supports today’s leading platforms, reflects new technical advances and best practices, and aligns with Version 4 of the Single UNIX Specification. Steve carefully retains the spirit and approach that have made this book so valuable. Building on Rich’s pioneering work, he begins with files, directories, and processes, carefully laying the groundwork for more advanced techniques, such as signal handling and terminal I/O. He also 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. Most obsolete interfaces have been removed, except for a few that are ubiquitous. Nearly all examples have been tested on four modern platforms: Solaris 10, Mac OS X version 10.6.8 (Darwin 10.8.0), FreeBSD 8.0, and Ubuntu version 12.04 (based on Linux 3.2). As in previous editions, you’ll learn through 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 you’ve learned, the book presents several chapter-length case studies, each reflecting contemporary environments. Advanced Programming in the UNIX® Environment has helped generations of programmers write code with exceptional power, performance, and reliability. Now updated for today’s systems, this third edition will be even more valuable
دانلود کتاب Advanced Programming in the UNIX® Environment (3rd edition)