Book description
“This is an excellent introduction to Linux programming. The topics are well chosen and lucidly presented. I learned things myself, especially about internationalization, and I’ve been at this for quite a while.”
—Chet Ramey, Coauthor and Maintainer of the Bash shell
“This is a good introduction to Linux programming. Arnold’s technique of showing how experienced programmers use the Linux programming interfaces is a nice touch, much more useful than the canned programming examples found in most books.”
—Ulrich Drepper, Project Lead, GNU C library
“A gentle yet thorough introduction to the art of UNIX system programming, Linux Programming by Example uses code from a wide range of familiar programs to illustrate each concept it teaches. Readers will enjoy an interesting mix of in-depth API descriptions and portability guidelines, and will come away well prepared to begin reading and writing systems applications. Heartily recommended.”
—Jim Meyering, Coauthor and Maintainer of the GNU Core Utility Programs
Learn Linux® programming, hands-on… from real source code
This book teaches Linux programming in the most effective way possible: by showing and explaining well-written programs. Drawing from both V7 Unix® and current GNU source code, Arnold Robbins focuses on the fundamental system call APIs at the core of any significant program, presenting examples from programs that Linux/Unix users already use every day. Gradually, one step at a time, Robbins teaches both high-level principles and “under the hood” techniques. Along the way, he carefully addresses real-world issues like performance, portability, and robustness. Coverage includes:
Memory management
File I/O
File metadata
Processes
Users and groups
Sorting and searching
Argument parsing
Extended interfaces
Signals
Internationalization
Debugging
And more…
Just learning to program? Switching from Windows®? Already developing with Linux but interested in exploring the system call interface further? No matter which, quickly and directly, this book will help you master the fundamentals needed to build serious Linux software.
Companion Web Sites,authors.phptr.com/robbins and www.linux-by-example.com, include all code examples.
Table of contents
- Copyright
- Preface
-
I. Files and Users
- 1. Introduction
- 2. Arguments, Options, and the Environment
-
3. User-Level Memory Management
- 3.1. Linux/Unix Address Space
-
3.2. Memory Allocation
-
3.2.1. Library Calls: malloc(), calloc(), realloc(), free()
- 3.2.1.1. Examining C Language Details
- 3.2.1.2. Initially Allocating Memory: malloc()
- 3.2.1.3. Releasing Memory: free()
- 3.2.1.4. Changing Size: realloc()
- 3.2.1.5. Allocating and Zero-filling: calloc()
- 3.2.1.6. Summarizing from the GNU Coding Standards
- 3.2.1.7. Using Private Allocators
- 3.2.1.8. Example: Reading Arbitrarily Long Lines
- 3.2.1.9. GLIBC Only: Reading Entire Lines: getline() and getdelim()
- 3.2.2. String Copying: strdup()
- 3.2.3. System Calls: brk() and sbrk()
- 3.2.4. Lazy Programmer Calls: alloca()
- 3.2.5. Address Space Examination
-
3.2.1. Library Calls: malloc(), calloc(), realloc(), free()
- 3.3. Summary
- Exercises
- 4. Files and File I/O
- 5. Directories and File Metadata
-
6. General Library Interfaces — Part 1
- 6.1. Times and Dates
- 6.2. Sorting and Searching Functions
- 6.3. User and Group Names
- 6.4. Terminals: isatty()
- 6.5. Suggested Reading
- 6.6. Summary
- Exercises
- 7. Putting It All Together: ls
- 8. Filesystems and Directory Walks
-
II. Processes, IPC, and Internationalization
-
9. Process Management and Pipes
- 9.1. Process Creation and Management
- 9.2. Process Groups
- 9.3. Basic Interprocess Communication: Pipes and FIFOs
- 9.4. File Descriptor Management
- 9.5. Example: Two-Way Pipes in gawk
- 9.6. Suggested Reading
- 9.7. Summary
- Exercises
-
10. Signals
- 10.1. Introduction
- 10.2. Signal Actions
- 10.3. Standard C Signals: signal() and raise()
- 10.4. Signal Handlers in Action
- 10.5. The System V Release 3 Signal APIs: sigset() et al.
-
10.6. POSIX Signals
- 10.6.1. Uncovering the Problem
- 10.6.2. Signal Sets: Sigset_t and Related Functions
- 10.6.3. Managing the Signal Mask: sigprocmask() et al.
- 10.6.4. Catching Signals: sigaction()
- 10.6.5. Retrieving Pending Signals: sigpending()
- 10.6.6. Making Functions Interruptible: siginterrupt()
- 10.6.7. Sending Signals: kill() and killpg()
- 10.6.8. Our Story So Far, Episode II
- 10.7. Signals for Interprocess Communication
- 10.8. Important Special-Purpose Signals
- 10.9. Signals Across fork() and exec()
- 10.10. Summary
- Exercises
-
11. Permissions and User and Group ID Numbers
- 11.1. Checking Permissions
- 11.2. Retrieving User and Group IDs
- 11.3. Checking as the Real User: access()
- 11.4. Checking as the Effective User: euidaccess() (GLIBC)
- 11.5. Setting Extra Permission Bits for Directories
- 11.6. Setting Real and Effective IDs
- 11.7. Working with All Three IDs: getresuid() and setresuid() (Linux)
- 11.8. Crossing a Security Minefield: Setuid root
- 11.9. Suggested Reading
- 11.10. Summary
- Exercises
- 12. General Library Interfaces — Part 2
-
13. Internationalization and Localization
- 13.1. Introduction
-
13.2. Locales and the C Library
- 13.2.1. Locale Categories and Environment Variables
- 13.2.2. Setting the Locale: setlocale()
- 13.2.3. String Collation: strcoll() and strxfrm()
- 13.2.4. Low-Level Numeric and Monetary Formatting: localeconv()
- 13.2.5. High-Level Numeric and Monetary Formatting: strfmon() and printf()
- 13.2.6. Example: Formatting Numeric Values in gawk
- 13.2.7. Formatting Date and Time Values: ctime() and strftime()
- 13.2.8. Other Locale Information: nl_langinfo()
-
13.3. Dynamic Translation of Program Messages
- 13.3.1. Setting the Text Domain: textdomain()
- 13.3.2. Translating Messages: gettext()
- 13.3.3. Working with Plurals: ngettext()
- 13.3.4. Making gettext() Easy to Use
- 13.3.5. Rearranging Word Order with printf()
- 13.3.6. Testing Translations in a Private Directory
- 13.3.7. Preparing Internationalized Programs
- 13.3.8. Creating Translations
- 13.4. Can You Spell That for Me, Please?
- 13.5. Suggested Reading
- 13.6. Summary
- Exercises
- 14. Extended Interfaces
-
9. Process Management and Pipes
-
III. Debugging and Final Project
- 15. Debugging
- 16. A Project that Ties Everything Together
- IV. Appendixes
Product information
- Title: Linux® Programming by Example
- Author(s):
- Release date: April 2004
- Publisher(s): Pearson
- ISBN: 0131429647
You might also like
book
Advanced UNIX Programming
Advanced UNIX Programming goes beyond the fundamentals of UNIX programming and presents information and techniques the …
book
Advanced UNIX Programming, Second Edition
The classic guide to UNIX® programming-completely updated! UNIX application programming requires a mastery of system-level services. …
book
Shell Programming in Unix, Linux and OS X, Fourth Edition
Shell Programming in Unix, Linux and OS X is a thoroughly updated revision of Kochan and …
book
Pro Bash Programming: Scripting the GNU/Linux Shell
The bash shell is a complete programming language, not merely a glue to combine external Linux …