Advanced Programming in the UNIX Environment (3rd Edition)

Rs. 4,350
  • Authors: W. Richard Stevens, Stephen A. Rago
  • ISBN: 9789332575905
  • Publisher: Pearson Education
  • Publication Date: January 1, 2017
  • Format: Paperback – 1032 pages
  • Language: English


Share
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
  1. Foreword to the Second Edition xix
  2. Preface xxi
  3. Preface to the Second Edition xxv
  4. Preface to the First Edition xxix
  5. Chapter 1: UNIX System Overview 1
    1. Introduction 1
    2. UNIX Architecture 1
    3. Logging In 2
    4. Files and Directories 4
    5. Input and Output 8
    6. Programs and Processes 10
    7. Error Handling 14
    8. User Identification 16
    9. Signals 18
    10. Time Values 20
    11. System Calls and Library Functions 21
    12. Summary 23
  6. Chapter 2: UNIX Standardization and Implementations 25
    1. Introduction 25
    2. UNIX Standardization 25
    3. UNIX System Implementations 33
    4. Relationship of Standards and Implementations 36
    5. Limits 36
    6. Options 53
    7. Feature Test Macros 57
    8. Primitive System Data Types 58
    9. Differences Between Standards 58
    10. Summary 60
  7. Chapter 3: File I/O 61
    1. Introduction 61
    2. File Descriptors 61
    3. open and openat Functions 62
    4. creat Function 66
    5. close Function 66
    6. lseek Function 66
    7. read Function 71
    8. write Function 72
    9. I/O Efficiency 72
    10. File Shar ing 74
    11. Atomic Operations 77
    12. dup and dup2 Functions 79
    13. sync, fsync, and fdatasync Functions 81
    14. fcntl Function 82
    15. ioctl Function 87
    16. /dev/fd 88
    17. Summary 90
  8. Chapter 4: Files and Directories 93
    1. Introduction 93
    2. stat, fstat, fstatat, and lstat Functions 93
    3. File Types 95
    4. Set-User-ID and Set-Group-ID 98
    5. File Access Per missions 99
    6. Ownership of New Files and Directories 101
    7. access and faccessat Functions 102
    8. umask Function 104
    9. chmod, fchmod, and fchmodat Functions 106
    10. Sticky Bit 108
    11. chown, fchown, fchownat, and lchown Functions 109
    12. File Size 111
    13. File Tr uncation 112
    14. File Systems 113
    15. link, linkat, unlink, unlinkat, and remove Functions 116
    16. rename and renameat Functions 119
    17. Symbolic Links 120
    18. Creating and Reading Symbolic Links 123
    19. File Times 124
    20. futimens, utimensat, and utimes Functions 126
    21. mkdir, mkdirat, and rmdir Functions 129
    22. Reading Director ies 130
    23. chdir, fchdir, and getcwd Functions 135
    24. Device Special Files 137
    25. Summary of File Access Per mission Bits 140
    26. Summary 140
  9. Chapter 5: Standard I/O Library 143
    1. Introduction 143
    2. Streams and FILE Objects 143
    3. Standard Input, Standard Output, and Standard Error 145
    4. Buffering 145
    5. Opening a Stream 148
    6. Reading and Writing a Stream 150
    7. Line-at-a-Time I/O 152
    8. Standard I/O Efficiency 153
    9. Binary I/O 156
    10. Positioning a Stream 157
    11. For matted I/O 159
    12. Implementation Details 164
    13. Temporary Files 167
    14. Memory Streams 171
    15. Alternatives to Standard I/O 174
    16. Summary 175
  10. Chapter 6: System Data Files and Information 177
    1. Introduction 177
    2. Password File 177
    3. Shadow Passwords 181
    4. Group File 182
    5. Supplementary Group IDs 183
    6. Implementation Differences 184
    7. Other Data Files 185
    8. Login Accounting 186
    9. System Identification 187
    10. Time and Date Routines 189
    11. Summary 196
  11. Chapter 7: Process Environment 197
    1. Introduction 197
    2. main Function 197
    3. Process Termination 198
    4. Command-Line Arguments 203
    5. Environment List 203
    6. Memory Lay out of a C Program 204
    7. Shared Libraries 206
    8. Memory Allocation 207
    9. Environment Var iables 210
    10. setjmp and longjmp Functions 213
    11. getrlimit and setrlimit Functions 220
    12. Summary 225
  12. Chapter 8: Process Control 227
    1. Introduction 227
    2. Process Identifiers 227
    3. fork Function 229
    4. vfork Function 234
    5. exit Functions 236
    6. wait and waitpid Functions 238
    7. waitid Function 244
    8. wait3 and wait4 Functions 245
    9. Race Conditions 245
    10. exec Functions 249
    11. Changing User IDs and Group IDs 255
    12. Interpreter Files 260
    13. system Function 264
    14. Process Accounting 269
    15. User Identification 275
    16. Process Scheduling 276
    17. Process Times 280
    18. Summary 282
  13. Chapter 9: Process Relationships 285
    1. Introduction 285
    2. Terminal Logins 285
    3. Network Logins 290
    4. Process Groups 293
    5. Sessions 295
    6. Controlling Terminal 296
    7. tcgetpgrp, tcsetpgrp, and tcgetsid Functions 298
    8. Job Control 299
    9. Shell Execution of Programs 303
    10. Orphaned Process Groups 307
    11. FreeBSD Implementation 310
    12. Summary 312
  14. Chapter 10: Signals 313
    1. Introduction 313
    2. Signal Concepts 313
    3. signal Function 323
    4. Unreliable Signals 326
    5. Interrupted System Calls 327
    6. Reentrant Functions 330
    7. SIGCLD Semantics 332
    8. Reliable-Signal Terminology and Semantics 335
    9. kill and raise Functions 336
    10. alarm and pause Functions 338
    11. Signal Sets 344
    12. sigprocmask Function 346
    13. sigpending Function 347
    14. sigaction Function 349
    15. sigsetjmp and siglongjmp Functions 355
    16. sigsuspend Function 359
    17. abort Function 365
    18. system Function 367
    19. sleep, nanosleep, and clock_nanosleep Functions 373
    20. sigqueue Function 376
    21. Job-Control Signals 377
    22. Signal Names and Numbers 379
    23. Summary 381
  15. Chapter 11: Threads 383
    1. Introduction 383
    2. Thread Concepts 383
    3. Thread Identification 384
    4. Thread Creation 385
    5. Thread Termination 388
    6. Thread Synchronization 397
    7. Summary 422
  16. Chapter 12: Thread Control 425
    1. Introduction 425
    2. Thread Limits 425
    3. Thread Attributes 426
    4. Synchronization Attributes 430
    5. Reentrancy 442
    6. Thread-Specific Data 446
    7. Cancel Options 451
    8. Threads and Signals 453
    9. Threads and fork 457
    10. Threads and I/O 461
    11. Summary 462
  17. Chapter 13: Daemon Processes 463
    1. Introduction 463
    2. Daemon Characteristics 463
    3. Coding Rules 466
    4. Error Logging 469
    5. Single-Instance Daemons 473
    6. Daemon Conventions 474
    7. Client–Server Model 479
    8. Summary 480
  18. Chapter 14: Advanced I/O 481
    1. Introduction 481
    2. Nonblocking I/O 481
    3. Record Locking 485
    4. I/O Multiplexing 500
    5. Asynchronous I/O 509
    6. readv and writev Functions 521
    7. readn and writen Functions 523
    8. Memory-Mapped I/O 525
    9. Summary 531
  19. Chapter 15: Interprocess Communication 533
    1. Introduction 533
    2. Pipes 534
    3. popen and pclose Functions 541
    4. Coprocesses 548
    5. FIFOs 552
    6. XSI IPC 556
    7. Message Queues 561
    8. Semaphores 565
    9. Shared Memory 571
    10. POSIX Semaphores 579
    11. Client–Server Proper ties 585
    12. Summary 587
  20. Chapter 16: Network IPC: Sockets 589
    1. Introduction 589
    2. Socket Descriptors 590
    3. Addressing 593
    4. Connection Establishment 605
    5. Data Transfer 610
    6. Socket Options 623
    7. Out-of-Band Data 626
    8. Nonblocking and Asynchronous I/O 627
    9. Summary 628
  21. Chapter 17: Advanced IPC 629
    1. Introduction 629
    2. UNIX Domain Sockets 629
    3. Unique Connections 635
    4. Passing File Descriptors 642
    5. An Open Server, Version 1 653
    6. An Open Server, Version 2 659
    7. Summary 669
  22. Chapter 18: Terminal I/O 671
    1. Introduction 671
    2. Over view 671
    3. Special Input Characters 678
    4. Getting and Setting Terminal Attributes 683
    5. Terminal Option Flags 683
    6. stty Command 691
    7. Baud Rate Functions 692
    8. Line Control Functions 693
    9. Terminal Identification 694
    10. Canonical Mode 700
    11. Noncanonical Mode 703
    12. Terminal Window Size 710
    13. termcap, terminfo, and curses 712
    14. Summary 713
  23. Chapter 19: Pseudo Terminals 715
    1. Introduction 715
    2. Over view 715
    3. Opening Pseudo-Terminal Devices 722
    4. pty_fork Function 726
    5. pty Program 729
    6. Using the pty Program 733
    7. Advanced Features 740
    8. Summary 741
  24. Chapter 20: A Database Library 743
    1. Introduction 743
    2. History 743
    3. The Library 744
    4. Implementation Over view 746
    5. Centralized or Decentralized? 750
    6. Concurrency 752
    7. Building the Library 753
    8. Source Code 753
    9. Performance 781
    10. Summary 786
  25. Chapter 21: Communicating with a Network Printer 789
    1. Introduction 789
    2. The Inter net Printing Protocol 789
    3. The Hyper text Transfer Protocol 792
    4. Printer Spooling 793
    5. Source Code 795
    6. Summary 843
  26. Appendix A: Function Prototypes 845
  27. Appendix B: Miscellaneous Source Code 895
    1. B.1 Our Header File 895
    2. B.2 Standard Error Routines 898
  28. Appendix C: Solutions to Selected Exercises 905
  29. Bibliography 947
  30. 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
Weight2.100 kg
Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.