Advanced Programming in the UNIX® Environment
lily
(lily)
#1
- ptg
- 2.2 UNIX Standardization
- 2.2.1 ISOC2
- 2.2.2 IEEE POSIX
- 2.2.3 The Single UNIX Specification
- 2.2.4 FIPS
- 2.3 UNIX System Implementations
- 2.3.1 UNIX System V Release
- 2.3.2 4.4BSD
- 2.3.3 FreeBSD
- 2.3.4 Linux
- 2.3.5 Mac OS X
- 2.3.6 Solaris
- 2.3.7 Other UNIX Systems
- 2.4 Relationship of Standards and Implementations
- 2.5 Limits
- 2.5.1 ISOCLimits
- 2.5.2 POSIX Limits
- 2.5.3 XSI Limits
- Functions 2.5.4 sysconf,pathconf,andfpathconf
- 2.5.5 Indeterminate Runtime Limits
- 2.6 Options
- 2.7 Feature Test Macros
- 2.8 PrimitiveSystem Data Types
- 2.9 Differences Between Standards
- 2.10 Summary6
- Chapter 3. File I/O
- 3.1 Introduction
- 3.2 File Descr iptors
- 3.3 openandopenat Functions
- 3.4 creatFunction
- 3.5 closeFunction
- 3.6 lseekFunction
- 3.7 readFunction
- 3.8 writeFunction
- 3.9 I/O Efficiency
- 3.10 File Shar ing
- 3.11 Atomic Operations
- 3.12 dupanddup2 Functions
- 3.13 sync,fsync,and fdatasyncFunctions
- 3.14 fcntlFunction
- 3.15 ioctlFunction Contents xi
- 3.16 /dev/fd
- 3.17 Summary9
- Chapter 4. Files and Directories
- 4.1 Introduction
- 4.2 stat,fstat,fstatat,and lstatFunctions
- 4.3 FileTy pes
- 4.4 Set-User-ID and Set-Group-ID
- 4.5 File Access Per missions
- 4.6 Ownership of NewFiles and Directories
- 4.7 accessandfaccessat Functions
- 4.8 umaskFunction
- 4.9 chmod,fchmod,and fchmodatFunctions
- 4.10 Sticky Bit
- Functions 4.11 chown,fchown,fchownat,and lchown
- 4.12 File Size1
- 4.13 FileTr uncation
- 4.14 File Systems
- Functions 4.15 link,linkat,unlink, unlinkat,and remove
- 4.16 renameandrenameat Functions
- 4.17 Symbolic Links
- 4.18 Creating and Reading Symbolic Links
- 4.19 File Times
- 4.20 futimens,utimensat,andutimes Functions
- 4.21 mkdir,mkdirat,and rmdirFunctions
- 4.22 Reading Director ies
- 4.23 chdir,fchdir,and getcwdFunctions
- 4.24 Device Special Files
- 4.25 Summary of File Access Per mission Bits
- 4.26 Summary1
- Chapter 5. StandardI/O Library1
- 5.1 Introduction
- 5.2 Streams and FILEObjects
- Error 5.3 Standard Input, Standard Output, and Standard
- 5.4 Buffer ing
- 5.5 OpeningaStream
- 5.6 Reading and Writing a Stream xii Contents
- 5.7 Line-at-a-Time I/O
- 5.8 Standard I/O Efficiency
- 5.9 BinaryI/O
- 5.10 Positioning a Stream
- 5.11 For matted I/O
- 5.12 Implementation Details
- 5.13 Temporar y Files
- 5.14 MemoryStreams
- 5.15 Alternatives to Standard I/O
- 5.16 Summary1
- Chapter 6. System Data Files and Information
- 6.1 Introduction
- 6.2 Password File
- 6.3 ShadowPasswords
- 6.4 Group File
- 6.5 SupplementaryGroup IDs
- 6.6 Implementation Differences
- 6.7 Other Data Files
- 6.8 Login Accounting
- 6.9 System Identification
- 6.10 Time and Date Routines
- 6.11 Summary1
- Chapter 7. Process Environment
- 7.1 Introduction
- 7.2 mainFunction
- 7.3 ProcessTe rmination
- 7.4 Command-Line Arguments
- 7.5 Environment List
- 7.6 MemoryLay out of a C Program2
- 7.7 Shared Librar ies
- 7.8 MemoryAllocation
- 7.9 Environment Var iables
- 7.10 setjmpandlongjmp Functions
- 7.11 getrlimitandsetrlimit Functions
- 7.12 Summary2
- Chapter 8. Process Control
- 8.1 Introduction
- 8.2 Process Identifiers Contents xiii
- 8.3 forkFunction
- 8.4 vforkFunction
- 8.5 exitFunctions
- 8.6 waitandwaitpid Functions
- 8.7 waitidFunction
- 8.8 wait3andwait4 Functions
- 8.9 Race Conditions
- 8.10 execFunctions
- 8.11 Changing User IDs and Group IDs
- 8.12 Interpreter Files
- 8.13 systemFunction
- 8.14 Process Accounting
- 8.15 User Identification
- 8.16 Process Scheduling
- 8.17 Process Times
- 8.18 Summary2
- Chapter 9. Process Relationships
- 9.1 Introduction
- 9.2 Ter minal Logins
- 9.3 Networ k Logins
- 9.4 Process Groups
- 9.5 Sessions
- 9.6 ControllingTe rminal
- Functions 9.7 tcgetpgrp,tcsetpgrp,andtcgetsid
- 9.8 Job Control
- 9.9 Shell Execution of Programs
- 9.10 Orphaned Process Groups
- 9.11 FreeBSD Implementation
- 9.12 Summary3
- Chapter 10. Signals
- 10.1 Introduction
- 10.2 Signal Concepts
- 10.3 signalFunction
- 10.4 Unreliable Signals
- 10.5 Interrupted System Calls
- 10.6 Reentrant Functions
- 10.7 SIGCLDSemantics
- 10.8 Reliable-Signal Ter minology and Semantics xiv Contents
- 10.9 killandraise Functions
- 10.10 alarmandpause Functions
- 10.11 Signal Sets
- 10.12 sigprocmaskFunction
- 10.13 sigpendingFunction
- 10.14 sigactionFunction
- 10.15 sigsetjmpandsiglongjmp Functions
- 10.16 sigsuspendFunction
- 10.17 abortFunction
- 10.18 systemFunction
- Functions 10.19 sleep,nanosleep,and clock_nanosleep
- 10.20 sigqueueFunction
- 10.21 Job-Control Signals
- 10.22 Signal Names and Numbers
- 10.23 Summary3
- Chapter 11. Threads
- 11.1 Introduction
- 11.2 Thread Concepts
- 11.3 Thread Identification
- 11.4 Thread Creation
- 11.5 ThreadTe rmination
- 11.6 Thread Synchronization
- 11.6.1 Mutexes3
- 11.6.2 DeadlockAvoidance
- 11.6.3 pthread_mutex_timedlockFunction
- 11.6.4 Reader–Writer Locks
- 11.6.5 Reader–Writer Locking with Timeouts
- 11.6.6 ConditionVariables
- 11.6.7 Spin Locks
- 11.6.8 Barriers
- 11.7 Summary4
- Chapter 12. Thread Control
- 12.1 Introduction
- 12.2 Thread Limits
- 12.3 Thread Attr ibutes
- 12.4 Synchronization Attr ibutes
- 12.4.1 MutexAttr ibutes
- 12.4.2 Reader–Writer LockAttr ibutes Contents xv
- 12.4.3 ConditionVariable Attributes
- 12.4.4 Barrier Attributes
- 12.5 Reentrancy
- 12.6 Thread-Specific Data
- 12.7 Cancel Options
- 12.8 Threads and Signals
- 12.9 Threads andfork
- 12.10 Threads and I/O
- 12.11 Summary4
- Chapter 13. Daemon Processes
- 13.1 Introduction
- 13.2 Daemon Character istics
- 13.3 Coding Rules
- 13.4 Error Logging
- 13.5 Single-Instance Daemons
- 13.6 Daemon Conventions
- 13.7 Client–ServerModel
- 13.8 Summary4
- Chapter 14. Advanced I/O
- 14.1 Introduction
- 14.2 Nonblocking I/O
- 14.3 Record Locking
- 14.4 I/O Multiplexing
- 14.4.1 selectandpselect Functions
- 14.4.2 pollFunction
- 14.5 Asynchronous I/O
- 14.5.1 SystemVAsynchronous I/O
- 14.5.2 BSD Asynchronous I/O
- 14.5.3 POSIX Asynchronous I/O
- 14.6 readvandwritev Functions
- 14.7 readnandwriten Functions
- 14.8 Memory-Mapped I/O
- 14.9 Summary5
- Chapter 15. Interprocess Communication
- 15.1 Introduction
- 15.2 Pipes
- 15.3 popenandpclose Functions
- 15.4 Coprocesses xvi Contents
- 15.5 FIFOs
- 15.6 XSI IPC
- 15.6.1 Identifiers and Keys5
- 15.6.2 Per mission Str ucture
- 15.6.3 Configuration Limits
- 15.6.4 Advantages and Disadvantages
- 15.7 Message Queues
- 15.8 Semaphores
- 15.9 Shared Memor y
- 15.10 POSIX Semaphores
- 15.11 Client–ServerProper ties
- 15.12 Summary5
- Chapter 16. Network IPC: Sockets
- 16.1 Introduction
- 16.2 SocketDescr iptors
- 16.3 Addressing
- 16.3.1 Byte Order ing
- 16.3.2 AddressFormats
- 16.3.3 Address Lookup
- 16.3.4 Associating Addresses with Sockets
- 16.4 Connection Establishment
- 16.5 DataTr ansfer
- 16.6 SocketOptions
- 16.7 Out-of-Band Data
- 16.8 Nonblocking and Asynchronous I/O
- 16.9 Summary6
- Chapter 17. Advanced IPC
- 17.1 Introduction
- 17.2 UNIX Domain Sockets
- 17.2.1 Naming UNIX Domain Sockets
- 17.3 Unique Connections
- 17.4 Passing File Descriptors
- 17.5 An Open Server, Version
- 17.6 An Open Server, Version
- 17.7 Summary6
- Chapter 18. Terminal I/O
- 18.1 Introduction
- 18.2 Over view6 Contents xvii
- 18.3 Special Input Characters
- 18.4 Getting and Setting Ter minal Attr ibutes
- 18.5 Ter minal Option Flags
- 18.6 sttyCommand
- 18.7 Baud Rate Functions
- 18.8 Line Control Functions
- 18.9 Ter minal Identification
- 18.10 Canonical Mode
- 18.11 Noncanonical Mode
- 18.12 Ter minal WindowSize7
- 18.13 termcap,terminfo,and curses
- 18.14 Summary7
- Chapter 19. Pseudo Terminals
- 19.1 Introduction
- 19.2 Over view7
- 19.3 Opening Pseudo-Ter minal Devices
- 19.4 pty_forkFunction
- 19.5 ptyProgram7
- 19.6 Using thepty Program7
- 19.7 Advanced Features
- 19.8 Summary7
- Chapter 20. ADatabase Library7
- 20.1 Introduction
- 20.2 History7
- 20.3 The Librar y
- 20.4 Implementation Over view7
- 20.5 Centralized or Decentralized?
- 20.6 Concurrency
- 20.7 Building the Librar y
- 20.8 Source Code
- 20.9 Perfor mance
- 20.10 Summary7
- Chapter 21. Communicating with a Network Printer
- 21.1 Introduction
- 21.2 The Inter net Pr inting Protocol
- 21.3 The Hyper text Transfer Protocol
- 21.4 Printer Spooling
- 21.5 Source Code xviii Contents
- 21.6 Summary8
- Appendix A. Function Prototypes
- Appendix B. Miscellaneous Source Code
- B.1Our Header File
- B.2Standard Error Routines
- Appendix C. Solutions to Selected Exercises
- Bibliography9
- Index9