Linux Application Development, Second Edition

book cover
Linux Application Development, Second Edition
By Michael K. Johnson, Erik W. Troan
Publisher: Addison Wesley Professional
Pub Date: November 17, 2004
Print ISBN-10: 0-321-21914-7
Print ISBN-13: 978-0-321-21914-5
Pages: 736
start reading online

Table of Contents  | Index


"The first edition of this book has always been kept within arm's reach of my desk due to the wonderful explanations of all areas of the Linux userspace API. This second edition greatly overshadows the first one, and will replace it." -Greg Kroah-Hartman, Linux kernel programmer

Develop Software that Leverages the Full Power of Today's Linux

Linux Application Development, Second Edition, is the definitive reference for Linux programmers at all levels of experience, including C programmers moving from other operating systems. Building on their widely praised first edition, leading Linux programmers Michael Johnson and Erik Troan systematically present the key APIs and techniques you need to create robust, secure, efficient software or to port existing code to Linux.

This book has been fully updated for the Linux 2.6 kernel, GNU C library version 2.3, the latest POSIX standards, and the Single Unix Specification, Issue 6. Its deep coverage of Linux-specific extensions and features helps you take advantage of the full power of contemporary Linux. Along the way, the authors share insights, tips, and tricks for developers working with any recent Linux distribution, and virtually any version of Unix.

Topics include

  • Developing in Linux: understanding the operating system, licensing,

  • and documentation

  • The development environment: compilers, linker and loader, and unique

  • debugging tools

  • System programming: process models, file handling, signal processing, directory operations, and job control

  • Terminals, sockets, timers, virtual consoles, and the Linux console

  • Development libraries: string matching, terminal handling, command-line parsing, authentication, and more

  • Hundreds of downloadable code samples

New to this edition

  • The GNU C library (glibc), underlying standards, and test macros

  • Writing secure Linux programs, system daemons, and utilities

  • Significantly expanded coverage of memory debugging, including Valgrind and mpr

  • Greatly improved coverage of regular expressions

  • IPv6 networking coverage, including new system library interfaces for using IPv6 and IPv4 interchangeably

  • Coverage of strace, ltrace, real-time signals, poll and epoll system calls, popt library improvements, Pluggable Authentication Modules (PAM), qdbm, and much more

  • Improved index and glossary, plus line-numbered code examples


editorial reviews
Book Description
This practical reference guides programmers developing Linux applications or porting applications from other platforms. Linux is fundamentally similar to Unix-so, much of the book covers ground familiar to Unix programmers-but this book consistently addresses topics from a Linux point of view. The aim throughout is to provide the detailed information you need to take full advantage of Linux.

If you are already a proficient Unix programmer, this book will greatly facilitate your transition to Linux. You will also find helpful discussions of some tricky Unix topics, such as process and session groups, job control, and tty handling.

If you are a C programmer, but know neither Unix nor Linux, reading this book in its entirety and working with its numerous examples will give you a solid introduction to Linux programming.

If you are already a Linux programmer, this book's clear treatment of advanced and otherwise confusing topics will surely make your programming tasks easier.

Linux Application Development is divided into four parts. Part 1 introduces you to Linux(the operating system, licenses, and documentation. Part 2 covers the most important aspects of the development environment(the compilers, linker, loader, and debugging tools. Part 3-the heart of the book-describes the interface to the kernel and to the core system libraries, including discussion of the process model, file handling, directory operations, signal processing (including the Linux signal API), job control, the POSIX( termios interface, sockets, and the Linux console. Part 4 describes important development libraries with interfaces more independent of the kernel. The source code from the book is freely available at


reader reviews from amazon ranked by helfulness

Average Customer Rating: 4.5 based on 34 reviews.
A lot of good info in one place, but organization needs work, 2005-02-15
Reviewer rating: 4
The Linux operating system provides a sophisticated framework for running programs. Within its sturdy covers, Linux Application Development by Michael K. Johnson and Erik W. Troan provides much of what intermediate to advanced programmers need to know to take advantage of that framework.

The book is divided into four major parts: Getting Started, Development Tools and Environment, System Programming and Development Libraries.

Part 1 - Getting Started, is a very high-level overview of Linux itself. The three chapters cover barely 20 pages, and discuss the history of Linux, its licensing, and the online documentation.

Part 2 - Development Tools and Environment gets more detailed, but ends up as a medium-level view of what tools you might use to actually create and debug your application. Six chapters covering about 75 pages discuss editors (Emacs and vi), make, the GNU debugger gdb, tracing, gcc options, glibc, memory debugging tools, libraries, and the environment. Each chapter feels a little light-weight except for the one on memory debugging tools.

If the first two parts seemed to just skim the surface somewhat, Part 3 - System Programming definitely dives into the deep end of the pool. Part 3 has 13 chapters and covers 450 pages, almost two-thirds of the total book. My major complaint with Part 3 is that related chapters appear to be separated by others. Five major groups of functionality are covered.

The Unix/Linux process model is explained in detail in Chapter 10, and should be followed by chapter 15, which goes into job control. File handling is introduced in chapter 11, expanded in chapter 13, and directory handling is covered in chapter 14. Interprocess communication is discussed in chapters 12 - Signal Processing (discussing simple semaphores) and chapter 17 - Networking with Sockets, which extends IPC across the network. User interfaces are covered in chapters 16 (terminals and pseudo-terminals), 20 (virtual consoles), and 21 (text-based interfaces for the Linux console). Timers, encryption, and writing secure programs are the topics of chapters 18, 19, and 22.

Finally, Part 4 covers the various development libraries commonly available to the programmer. Chapter 23 covers the ins and outs of string handling and regular expressions. Using S-Lang to handle the terminal is the main interest of the next chapter. Chapter 25 discusses database interfaces, specifically qdbm, which is licensed under the LGPL. Traditional option functions getopt and getopt_long and their cousin on steriods popt are detailed in the following chapter. The final two chapters cover dynamic loading of shared objects with the advantages that provides, and user identification and authentication, covering id-to-name translation, and Pluggable Authentication Modules (PAM).

This book has a lot of information packed within its covers, When programming, one needs a number of reference books at hand, and Linux Application Development should definitely be one of the handiest. My only concerns were how the first two parts seemed skimpy compared to the rest of the book, and the part on System Programming could have been laid out better. That said, Linux Application Development rates a 4 out of 5.
Will become a well-worn addition to your programming shelf.., 2005-01-08
Reviewer rating: 4
(This review is for the second edition)

If you're involved in trying to port software to a Unix/Linux application platform, you should get a copy of the 2nd edition of Linux Application Development by Michael K. Johnson and Erik W. Troan (Addison Wesley). This will become a key part of your learning.

Chapter Breakout:
Part 1 - Getting Started - History Of Linux Development; Licenses And Copyright; Online System Documentation
Part 2 - Development Tools And Environment - Development Tools; gcc Options And Extensions; The GNU C Library; Memory Debugging Tools; Creating And Using Libraries; Linux System Environment
Part 3 - System Programming - The Process Model; Simple File Handling; Signal Processing; Advanced File Handling; Directory Operations; Job Control; Terminals And Pseudo Terminals; Networking With Sockets; Time; Random Numbers; Programming Virtual Consoles; The Linux Console; Writing Secure Programs
Part 4 - Development Libraries - String Matching; Terminal Handling With S-Lang; A Hashed Database Library; Parsing Command-Line Options; Dynamic Loading At Run Time; User Identification And Authentication
Appendix A - Header Files; Appendix B - ladsh Source Code; Glossary; Bibliography; Index

With the recent rapid uptake of Linux-based servers and desktops, more and more companies are looking at porting their software from Windows platforms over to Linux. The trouble with porting in that instance is that the underlying operating system dependancies are all different, and unless you understand how to work with the OS, you're lost. Linux Application Development does an excellent job in first introducing the common tools that are used for application development on Linux. The assumption is that you'll be programming in C, but within that framework the authors explain each tool and how it can aid in developing your system (such as memory-checking tools that come with the GNU C library). Once the subject of application development environments is finished, they move on to the actual OS and how it should interface with the application. The book presents a lot of code for examples, as well as explaining exactly why things work as they do. By the time you've gotten to the end of the material, you should have a more-than-adequate understanding of how to build applications for Linux/Unix.

Excellent material for the application developer who needs to build on the Linux platform...
Excellent C language introduction, 2005-01-01
Reviewer rating: 4
This is a well written introduction to C development on Linux starting with the very basics of process and file I/O, going all the way through networking, regular expressions and lightweight databases. The first few chapters go over the differences between Linux and unix. Then cover development tool basics.

This is a high end reference that is light on screenshots (almost none), that has well written and annotated example code. It's reminiscent of the classic Advanced Unix Programming. With the exception that this book is larger and has better exposition. In particular this book will answer almost any question you have about file I/O, process management, and networking.

This is an excellent book. It gets my full recommendation.
easy migration from any Unix, 2004-12-19
Reviewer rating: 4
[A review of the SECOND EDITION, Dec 2004.]

Are you a C programmer working on a unix box? And you have to port your application to linux? There can be understandable trepidation about migration. Because the biggest issue may not be the free linux versus a proprietary operating system. For application development, the cost of an operating system isn't usually a big deal. More important are the compiler and types of native library support you get. Hence the authors fill in a lot of practical details about linux. The book's title doesn't say so, but the language covered is C. Not Java or C++. Though in fact much of the book's remarks will also apply to C++. And there is no fancy GUI. The book goes back to the basics of C development.

Unix veterans will catch on quickly. The book's description of file handling, general I/O handling, sockets, directory operations and other issues is really no different than going to a given unix. Daresay that you'll be pleased to know that over 90% of your unix knowledge is eminently reusable. And the GNU C compiler used in the book should already be a close friend.

Granted that if you're porting an application specific to a unix, there might be low level unpleasantries. But hopefully, good design and having this book will mitigate the migration.
How to talk to the Operating System, 2004-12-08
Reviewer rating: 5
This is an almost beginners book on programming at the Linux operating system level. It is not a book on C itself, but you could probably use it as one. It's real emphasis is on the system call, shared library, file handling level. That is, how to interface directly to the operating system itself to get it to perform what you need it to do.

The bookis aimed at three audiences: C programmers who need to know how to get to the Linux operating system, Unix programmers who need to make the transition to Linux (no they're not the same), Linux programmers who need to move upwards in their understanding of the operating system. It does these jobs very well. The authors each spent years at Red Hat developing their releases, have a throrough understanding of Linux and the ability to convey that information to the reader in a clear and understandable manner.


start reading online