Contents At a Glance

I. Advanced UNIX Programming with Linux

1. Getting Started

2. Writing Good GNU/Linux Software

3. Processes

4. Threads

5. Interprocess Communication

II. Mastering Linux

6. Devices

7. The /proc File System

8. Linux System Calls

9. Inline Assembly Code

10. Security

11. A Sample GNU/Linux Application

III. Appendixes

A. Other Development Tools

B. Low-Level I/O

C. Table of Signals

D. Online Resources

E. Open Publication License Version 1.0

F. GNU General Public License

Table of Contents

I. Advanced UNIX Programming with Linux

1. Getting Started

1.1 Editing with Emacs

1.2 Compiling with GCC

1.3 Automating the Process with GNU Make

1.4 Debugging with GNU Debugger (GDB)

1.5 Finding More Information

2. Writing Good GNU/Linux Software

2.1 Interaction With the Execution Environment

2.2 Coding Defensively

2.3 Writing and Using Libraries

3. Processes

3.1 Looking at Processes

3.2 Creating Processes

3.3 Signals

3.4 Process Termination

4. Threads

4.1 Thread Creation

4.2 Thread Cancellation

4.3 Thread-Specific Data

4.4 Synchronization and Critical Sections

4.5 GNU/Linux Thread Implementation

4.6 Processes Vs. Threads

5. Interprocess Communication

5.1 Shared Memory

5.2 Processes Semaphores

5.3 Mapped Memory

5.4 Pipes

5.5 Sockets

II. Mastering Linux

6. Devices

6.1 Device Types

6.2 Device Numbers

6.3 Device Entries

6.4 Hardware Devices

6.5 Special Devices

6.6 PTYs

6.7 ioctl

7. The /proc File System

7.1 Extracting Information from /proc

7.2 Process Entries

7.3 Hardware Information

7.4 Kernel Information

7.5 Drives, Mounts, and File Systems

7.6 System Statistics

8. Linux System Calls

8.1 Using strace

8.2 access: Testing File Permissions

8.3 fcntl: Locks and Other File Operations

8.4 fsync and fdatasync: Flushing Disk Buffers

8.5 getrlimit and setrlimit: Resource Limits

8.6 getrusage: Process Statistics

8.7 gettimeofday: Wall-Clock Time

8.8 The mlock Family: Locking Physical Memory

8.9 mprotect: Setting Memory Permissions

8.10 nanosleep: High-Precision Sleeping

8.11 readlink: Reading Symbolic Links

8.12 sendfile: Fast Data Transfers

8.13 setitimer: Setting Interval Timers

8.14 sysinfo: Obtaining System Statistics

8.15 uname

9. Inline Assembly Code

9.1 When to Use Assembly Code

9.2 Simple Inline Assembly

9.3 Extended Assembly Syntax

9.4 Example

9.5 Optimization Issues

9.6 Maintenance and Portability Issues

10. Security

10.1 Users and Groups

10.2 Process User IDs and Process Group IDs

10.3 File System Permissions

10.4 Real and Effective IDs

10.5 Authenticating Users

10.6 More Security Holes

11. A Sample GNU/Linux Application

11.1 Overview

11.2 Implementation

11.3 Modules

11.4 Using the Server

11.5 Finishing Up

III. Appendixes

A. Other Development Tools

A.1 Static Program Analysis

A.2 Finding Dynamic Memory Errors

A.3 Profiling

B. Low-Level I/O

B.1 Reading and Writing Data

B.2 stat

B.3 Vector Reads and Writes

B.4 Relation to Standard C Library I/O Functions

B.5 Other File Operations

B.6 Reading Directory Contents

C. Table of Signals

D. Online Resources

D.1 General Information

D.2 Information About GNU/Linux Software

D.3 Other Sites

E. Open Publication License Version 1.0

I. Requirements on Both Unmodified and Modified Versions

II. Copyright

III. Scope of License

IV. Requirements on Modified Works

V. Good-Practice Recommendations

VI. License Options

Open Publication Policy Appendix

F. GNU General Public License

Preamble

Terms and Conditions for Copying, Distribution and Modification

End of Terms and Conditions

Index

Table of Program Listings

1.1 main.c (C source file)

1.2 reciprocal.cpp (C++ source file)

1.3 reciprocal.hpp (header file)

2.1 arglist.c (argc and argv parameters)

2.2 getopt_long.c (getopt_long function)

2.3 print_env.c (printing execution environment)

2.4 client.c (network client program)

2.5 temp_file.c (mkstemp function)

2.6 readfile.c (resource allocation during error checking)

2.7 test.c (library contents)

2.8 app.c (program with library functions)

2.9 tifftest.c (libtiff library)

3.1 print-pid.c (printing process IDs)

3.2 system.c (system function)

3.3 fork.c (fork function)

3.4 fork-exec.c (fork and exec functions)

3.5 sigusr1.c (signal handlers)

3.6 zombie.c (zombie processes)

3.7 sigchld.c (cleaning up child processes)

4.1 thread-create.c (creating threads)

4.2 thread-create2 (creating two threads)

4.3 thread-create2.c (revised main function)

4.4 primes.c (prime number computation in a thread)

4.5 detached.c (creating detached threads)

4.6 critical-section.c (critical sections)

4.7 tsd.c (thread-specific data)

4.8 cleanup.c (cleanup handlers)

4.9 cxx-exit.cpp (C++ thread cleanup)

4.10 job-queue1.c (thread race conditions)

4.11 job-queue2.c (mutexes)

4.12 job-queue3.c (semaphores)

4.13 spin-condvar.c (condition variables)

4.14 condvar.c (condition variables)

4.15 thread-pid (printing thread process IDs)

5.1 shm.c (shared memory)

5.2 sem_all_deall.c (semaphore allocation and deallocation)

5.3 sem_init.c (semaphore initialization)

5.4 sem_pv.c (semaphore wait and post operations)

5.5 mmap-write.c (mapped memory)

5.6 mmap-read.c (mapped memory)

5.7 pipe.c (parent-child process communication)

5.8 dup2.c (output redirection)

5.9 popen.c (popen command)

5.10 socket-server.c (local sockets)

5.11 socket-client.c (local sockets)

5.12 socket-inet.c (Internet-domain sockets)

6.1 random_number.c (random number generation)

6.2 cdrom-eject.c (ioctl example)

7.1 clock-speed.c (cpu clock speed from /proc/cpuinfo)

7.2 get-pid.c (process ID from /proc/self)

7.3 print-arg-list.c (printing process argument lists)

7.4 print-environment.c (process environment)

7.5 get-exe-path.c (program executable path)

7.6 open-and-spin.c (opening files)

7.7 print-uptime.c (system uptime and idle time)

8.1 check-access.c (file access permissions)

8.2 lock-file.c (write locks)

8.3 write_journal_entry.c (data buffer flushing)

8.4 limit-cpu.c (resource limits)

8.5 print-cpu-times.c (process statistics)

8.6 print-time.c (date/time printing)

8.7 mprotect.c (memory access)

8.8 better_sleep.c (high-precision sleep)

8.9 print-symlink.c (symbolic links)

8.10 copy.c (sendfile system call)

8.11 itemer.c (interal timers)

8.12 sysinfo.c (system statistics)

8.13 print-uname (version number and hardware information)

9.1 bit-pos-loop.c (bit position with loop)

9.2 bit-pos-asm.c (bit position with bsrl)

10.1 simpleid.c (printing user and group IDs)

10.2 stat-perm.c (viewing file permissions with stat system call)

10.3 setuid-test.c (setuid programs)

10.4 pam.c (PAM example)

10.5 temp-file.c (temporary file creation)

10.6 grep-dictionary.c (word search)

11.1 server.h (function and variable declarations)

11.2 common.c (utility functions)

11.3 module.c (loading server modules)

11.4 server.c (server implementation)

11.5 main.c (main server program)

11.6 time.c (show wall-clock time)

11.7 issue.c (GNU/Linux distribution information)

11.8 diskfree.c (free disk space information)

11.9 processes.c (summarizing running processes)

11.10 Makefile (Makefile for sample application program)

A.1 hello.c (Hello World)

A.2 malloc-use.c (dynamic memory allocation)

A.3 calculator.c (main calculator program)

A.4 number.c (unary number implementation)

A.5 stack.c (unary number stack)

A.6 definitions.h (header file for calculator program)

B.1 create-file.c (create a new file)

B.2 timestamp.c (append a timestamp)

B.3 write-all.c (write all buffered data)

B.4 hexdump.c (print a hexadecimal file dump)

B.5 lseek-huge.c (creating large files)

B.6 read-file.c (reading files into buffers)

B.7 write-args.c (writev function)

B.8 listdir.c (printing directory listings)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset