Table of contents for Advanced programming in the Unix environment / W. Richard Stevens, Stephen A. Rago.

Bibliographic record and links to related information available from the Library of Congress catalog.

Note: Contents data are machine generated based on pre-publication provided by the publisher. Contents may have variations from the printed book or be incomplete or contain other coding.


Counter
CONTENTS
Foreword
Preface xvii
Preface to the First Edition xxi
Chapter 1: UNIX System Overview 1
1.1 Introduction 1
1.2 UNIX Architecture 1
1.3 Logging In 2
1.4 Files and Directories 4
1.5 Input and Output 8
1.6 Programs and Processes 10
1.7 Error Handling 14
1.8 User Identification 16
1.9 Signals 18
1.10 Time Values 20
1.11 System Calls and Library Functions 21
1.12 Summary 23
Chapter 2: UNIX Standardization and Implementations 25
2.1 Introduction 25
2.2 UNIX Standardization 25
2.3 UNIX System Implementations 33
2.4 Relationship of Standards and Implementations 36
2.5 Limits 36
2.6 Options 52
2.7 Feature Test Macros 55
2.8 Primitive System Data Types 56
2.9 Conflicts Between Standards 56
2.10 Summary 58
Chapter 3: File I/O 59
3.1 Introduction 59
3.2 File Descriptors 59
3.3 open Function 60
3.4 creat Function 62
3.5 close Function 63
3.6 lseek Function 63
3.7 read Function 67
3.8 write Function 68
3.9 I/O Efficiency 68
3.10 File Sharing 70
3.11 Atomic Operations 74
3.12 dup and dup2 Functions 76
3.13 sync, fsync, and fdatasync Functions 77
3.14 fcntl Function 78
3.15 ioctl Function 83
3.16 /dev/fd 84
3.17 Summary 85
Chapter 4: Files and Directories 87
4.1 Introduction 87
4.2 stat, fstat, and lstat Functions 87
4.3 File Types 88
4.4 Set-User-ID and Set-Group-ID 91
4.5 File Access Permissions 92
4.6 Ownership of New Files and Directories 95
4.7 access Function 95
4.8 umask Function 97
4.9 chmod and fchmod Functions 99
4.10 Sticky Bit 101
4.11 chown, fchown, and lchown Functions 102
4.12 File Size 103
4.13 File Truncation 105
4.14 File Systems 105
4.15 link, unlink, remove, and rename Functions 108
4.16 Symbolic Links 112
4.17 symlink and readlink Functions 115
4.18 File Times 115
4.19 utime Function 116
4.20 mkdirand rmdir Functions 119
4.21 Reading Director ies 120
4.22 chdir, fchdir, and getcwd Functions 125
4.23 Device Special Files 127
4.24 Summary of File Access Permission Bits 130
4.25 Summary 130
Chapter 5: Standard I/O Library 133
5.1 Introduction 133
5.2 Streams and FILE Objects 133
5.3 Standard Input, Standard Output, and Standard Error 135
5.4 Buffering 135
5.5 Opening a Stream 138
5.6 Reading and Writing a Stream 140
5.7 Line-at-a-Time I/O 142
5.8 Standard I/O Efficiency 143
5.9 Binary I/O 145
5.10 Positioning a Stream 147
5.11 Formatted I/O 149
5.12 Implementation Details 153
5.13 Temporary Files 155
5.14 Alternatives to Standard I/O 159
5.15 Summary 159
Chapter 6. System Data Files and Information 161
6.1 Introduction 161
6.2 Password File 161
6.3 Shadow Passwords 165
6.4 Group File 166
6.5 Supplementary Group IDs 167
6.6 Implementation Differences 169
6.7 Other Data Files 169
6.8 Login Accounting 170
6.9 System Identification 171
6.10 Time and Date Routines 173
6.11 Summary 177
Chapter 7: Process Environment 179
7.1 Introduction 179
7.2 main Function 179
7.3 Process Termination 180
7.4 Command-Line Arguments 185
7.5 Environment List 185
7.6 Memory Layout of a C Program 186
7.7 Shared Libraries 188
7.8 Memory Allocation 189
7.9 Environment Variables 192
7.10 setjmp and longjmp Functions 195
7.11 getr limit and setr limit Functions 202
7.12 Summary 206
Chapter 8: Process Control 209
8.1 Introduction 209
8.2 Process Identifiers 209
8.3 fork Function 211
8.4 vfork Function 216
8.5 exit Functions 218
8.6 wait and waitpid Functions 220
8.7 waitid Function 227
8.8 wait3 and wait4 Functions 228
8.9 Race Conditions 228
8.10 exec Functions 232
8.11 Changing User IDs and Group IDs 238
8.12 Interpreter Files 243
8.13 system Function 247
8.14 Process Accounting 252
8.15 User Identification 258
8.16 Process Times 259
8.17 Summary 261
Chapter 9: Process Relationships 263
9.1 Introduction 263
9.2 Terminal Logins 263
9.3 Network Logins 268
9.4 Process Groups 271
9.5 Sessions 272
9.6 Controlling Terminal 274
9.7 tcgetpgrp, tcsetpgrp, and tcgetsid Functions 275
9.8 Job Control 276
9.9 Shell Execution of Programs 279
9.10 Orphaned Process Groups 285
9.11 FreeBSD Implementation 289
9.12 Summary 291
Chapter 10: Signals 293
10.1 Introduction 293
10.2 Signal Concepts 293
10.3 signal Function 302
10.4 Unreliable Signals 305
10.5 Interrupted System Calls 307
10.6 Reentrant Functions 310
10.7 SIGCLD Semantics 312
10.8 Reliable Signal Terminology and Semantics 315
10.9 kill and raise Functions 316
10.10 alarm and pause Functions 317
10.11 Signal Sets 323
10.12 sigprocmask Function 325
10.13 sigpending Function 326
10.14 sigaction Function 329
10.15 sigsetjmpand siglongjmp Functions 335
10.16 sigsuspend Function 339
10.17 abort Function 345
10.18 system Function 347
10.19 sleep Function 352
10.20 Job-Control Signals 354
10.21 Additional Features 357
10.22 Summary 358
Chapter 11: Threads 361
11.1 Introduction 361
11.2 Thread Concepts 361
11.3 Thread Identification 362
11.4 Thread Creation 363
11.5 Thread Termination 366
11.6 Thread Synchronization 374
11.7 Summary 392
Chapter 12: Thread Control 395
12.1 Introduction 395
12.2 Thread Limits 395
12.3 Thread Attributes 396
12.4 Synchronization Attributes 401
12.5 Reentrancy 409
12.6 Thread-Specific Data 414
12.7 Cancel Options 418
12.8 Threads and Signals 421
12.9 Threads and Fork 425
12.10 Threads and I/O 429
12.11 Summary 429
Chapter 13: Daemon Processes 431
13.1 Introduction 431
13.2 Daemon Character istics 431
13.3 Coding Rules 433
13.4 Error Logging 436
13.5 Single-Instance Daemons 440
13.6 Daemon Conventions 442
13.7 Client-Server Model 447
13.8 Summary 447
Chapter 14: Advanced I/O 449
14.1 Introduction 449
14.2 Nonblocking I/O 449
14.3 Record Locking 452
14.4 STREAMS 468
14.5 I/O Multiplexing 480
14.6 Asynchronous I/O 489
14.7 readv and writev Functions 491
14.8 readn and writen Functions 493
14.9 Memory-Mapped I/O 494
14.10 Summary 501
Chapter 15: Interprocess Communication 503
15.1 Introduction 503
15.2 Pipes 504
15.3 popen and pclose Functions 511
15.4 Coprocesses 518
15.5 FIFOs 522
15.6 XSI IPC 526
15.7 Message Queues 530
15.8 Semaphores 535
15.9 Shared Memor y 541
15.10 Client-Server Properties 550
15.11 Summary 552
Chapter 16: Network IPC: Sockets 555
16.1 Introduction 555
16.2 Socket Descriptors 556
16.3 Addressing 559
16.4 Connection Establishment 572
16.5 Data Transfer 575
16.6 Socket Options 590
16.7 Out-of-Band Data 592
16.8 Nonblocking and Asynchronous I/O 593
16.9 Summary 594
Chapter 17: Advanced IPC 597
17.1 Introduction 597
17.2 STREAMS-based Pipes 597
17.2.1 Naming STREAMS Pipes 601
17.2.2 Unique Connections 602
17.3 UNIX Domain Sockets 606
17.4 Passing File Descriptors 613
17.5 An Open Server, Version 1 626
17.6 An Open Server, Version 2 633
17.7 Summary 641
Chapter 18: Terminal I/O 643
18.1 Introduction 643
18.2 Overview 643
18.3 Special Input Characters 650
18.4 Getting and Setting Terminal Attributes 655
18.5 Terminal Option Flags 655
18.6 stty Command 663
18.7 Baud Rate Functions 664
18.8 Line Control Functions 665
18.9 Terminal Identification 666
18.10 Canonical Mode 672
18.11 Noncanonical Mode 675
18.12 Terminal Window Size 682
18.13 termcap, terminfo, and curses 684
18.14 Summary 685
Chapter 19: Pseudo Terminals 687
19.1 Introduction 687
19.2 Overview 687
19.3 Opening Pseudo-Terminal Devices 693
19.4 pty_fork Function 704
19.5 pty Program 706
19.6 Using the pty Program 710
19.7 Advanced Features 718
19.8 Summary 719
Chapter 20: A Database Library 721
20.1 Introduction 721
20.2 History 721
20.3 The Library 722
20.4 Implementation Overview 724
20.5 Centralized or Decentralized? 728
20.6 Concurrency 729
20.7 Building the Library 731
20.8 Source Code 731
20.9 Performance 760
20.10 Summary 765
Chapter 21: Communicating with a Network Printer 767
21.1 Introduction 767
21.2 The IPP Protocol 767
21.3 The HTTP Protocol 770
21.4 Printer Spooling 771
21.5 Source Code 772
21.6 Summary 819
Appendix A: Function Prototypes 821
Appendix B: Miscellaneous Source Code 857
B.1 Our Header File 857
B.2 Standard Error Routines 860
Appendix C: Solutions to Selected Exercises 867
Bibliography 899
Index 905

Library of Congress Subject Headings for this publication:

Operating systems (Computers).
UNIX (Computer file).