Home > Store

Linux Programming Unleashed, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

Linux Programming Unleashed, 2nd Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2000
  • Dimensions: 7-3/8" x 9-1/8"
  • Pages: 912
  • Edition: 2nd
  • Book
  • ISBN-10: 0-672-32021-5
  • ISBN-13: 978-0-672-32021-7

  • An expert guide written for intermediate to advanced Linux programmers
  • Covers how to program core systems, user interfaces, device drives, networks, and much more
  • Practical, tested examples of how to apply the best programming practices in the Linux environment

Downloads

Downloads


Source code for the book in tar/gzip format -- 1.3 Mb -- code.tar.gz
Source code for the book in tar/compress format -- 1.9 Mb -- code.tar.Z

Sample Content

Table of Contents



Introduction.

What This Book Will Do for You. Intended Audience. What's New in This Edition. How to Read This Book. Typographical Conventions Used in This Book.

I. THE LINUX PROGRAMMING TOOLKIT.

1. Linux and Linux Programming in Context.

Linux Comes of Age.

Linux Yesterday. Linux Today. Linux Tomorrow.

Why Linux Programming? What You'll Learn, Appendix By .

The Linux Programming Toolkit. Input, Output, Files, and Directories. Processes and Synchronization. Network Programming. Programming the User Interface. Special Topics. Finishing Touches.

Summary.

2. Setting Up a Development System.

General Considerations. The Motherboard and CPU.

Onboard I/O. Processor. BIOS. Memory. Cases and Power Supplies.

User Interaction Hardware: Video, Sound, Keyboards, and Mice.

Video Cards. Monitors. Sound Cards. Keyboards and Mice.

Communication Devices, Ports, and Buses.

Modems. Network Interface Cards. SCSI. USB and Firewire (IEEE 1394). Serial Cards. IRDA. PCMCIA Cards. ISA Plug and Play.

Storage Devices.

Hard Disks. Removable Disks. CD-ROM/DVD. Tape Backup.

External Peripherals.

Printers. Scanners. Digital Cameras. Home Automation.

Complete Systems. Laptops. Development Software.

Key Libraries and Header Files. Debuggers. Programming Utilities. Text Editors.

Summary.

3. Using the GNU Compiler Collection.

Features of GNU CC. Tutorial Example. Common Command-Line Options.

Working with Libraries and Include Files. Warning and Error Message Options.

Optimization Options. Debugging Options. Architecture-Specific Options. GNU C Extensions.

About Portability. GNU Extensions.

PGCC: The Pentium Compiler. Summary.

4. Project Management Using GNU make.

Why make? Writing Makefiles. Makefile Rules.

Phony Targets. Variables. Implicit Rules. Pattern Rules. Comments.

Command-Line Options and Arguments. Debugging make. Common make Error Messages. Useful Makefile Targets. Summary.

5. Creating Portable, Self-Configuring Software.

Considering Portability.

What Is Program Portability? Portability Hints and Tips.

Understanding Autoconf.

Building configure.in. Structuring the File. Helpful Autoconf Utilities.

Built-In Macros.

Tests for Alternative Programs. Tests for Library Functions. Tests for Header Files. Tests for Structures. Tests for typedefs. Tests of Compiler Behavior. Tests for System Services. Tests for UNIX Variants.

Generic Macros. An Annotated Autoconf Script. Summary.

6. Comparing and Merging Source Code Files.

Comparing Files Using the diff Command.

diff Command-Line Options and Arguments.

Understanding the diff3 Command. Preparing Source Code Patches.

patch Command-Line Options. Creating a Patch. Applying a Patch.

Summary.

7. Version Control Using RCS and CVS.

Basic Terminology. Using the Revision Control System (RCS).

Basic RCS Usage. Finding Differences Between RCS Files. Other RCS Commands.

Using the Concurrent Versions System (CVS).

Advantages over RCS. Setting Up CVS. Checking Out Source Files. Merging Changes into the Repository. Reviewing Changes. Adding and Deleting Files. Resolving File Conflicts. CVS Commands. CVS Options.

Summary.

8. Debugging.

Compiling for GDB. Using Basic GDB Commands.

Starting GDB. Inspecting Code in the Debugger. Examining Data. Setting Breakpoints. Examining and Changing Running Code.

Advanced GDB Concepts and Commands.

Variable Scope and Context. Traversing the Call Stack. Working with Source Files. Communicating with the Shell. Attaching to a Running Program.

Summary.

9. Handling Errors.

Error Handling Is the Right Thing. Error-Handling Options. C Language Facilities.

assert Yourself. Using the Preprocessor. Standard Library Functions.

Using the System Log.

System Logging Options. System Logging Functions. User Programs.

Summary.

10. Using Libraries

Working with Programming Libraries.

Library Compatibility. Naming and Numbering Conventions. Commonly Used Libraries.

Library Tools.

Understanding the nm Command. Understanding the ar Command. Understanding the ldd Command. Understanding ldconfig. Environment Variables and Configuration Files.

Writing and Using Static Libraries. Writing and Using Shared Libraries. Using Dynamically Loaded Shared Objects.

Understanding the dl Interface. Using the dl Interface.

Summary.

II. INPUT, OUTPUT, FILES, AND DIRECTORIES.

11. Input and Output.

Basic Characteristics and Concepts.

The File Mode.

Understanding File Descriptors.

What Is a File Descriptor? File Descriptor Advantages and Disadvantages.

Using File Descriptors.

Opening and Closing File Descriptors. Reading and Writing File Descriptors. Shortening Files: Using ftruncate. Positioning the File Pointer: Using lseek. Syncing to Disk: Using fsync. Obtaining File Information: Using fstat. Changing File Ownership: Using fchown. Changing File Permissions: Using fchmod. File Locking: Using flock and fcntl. Using The dup and dup2 Calls. Reading and Writing Multiple Files Simultaneously: Using select. The Swiss Army Knife: Using ioctl.

Summary.

12. Working with Files and Directories.

The Standard File Functions.

Opening and Closing Files. Reading and Writing Files. Getting File Status.

Input and Output Calls.

Formatted Output. Formatted Input. Character Input and Output. Line Input and Output. File Positioning. Buffer Control. Deleting and Renaming Files. Using Temporary Files.

Working with Directories.

Finding the Current Directory. Changing Directories. Creating and Deleting Directories. Obtaining Directory Listings.

Special ext2 Filesystem Attributes. Summary.

III. PROCESSES AND SYNCHRONIZATION.

13. Process Control.

The Linux Process Model. Process Attributes.

Process Identifiers. Real and Effective IDs. SetUID and SetGID Programs. User and Group Information. Additional Process Information.

Creating Processes.

Using the system Function. The fork System Call. The exec Family. Using the popen Function.

Manipulating Processes.

Waiting on Processes-The wait Family. Killing Programs.

Signals.

What Is a Signal? Sending Signals. Catching Signals. Detecting Signals.

Process Scheduling. Summary.

14. Introduction to Threads.

What Are Threads? The __clone Function Call. The Pthreads Interface.

What Are Pthreads? When to Use Pthreads. The pthread_create Function. The pthread_exit Function. The pthread_join Function. The pthread_atfork Function. Thread Cancellation. Pthread Cleanup Macros. Pthread Conditions. The pthread_equal Function. Thread Attributes. Mutexes.

Summary.

15. Accessing System Information.

Process Info.

The cmdline File. The environ File. The fd Directory. The mem File. stat. The status File. The cwd Symbolic Link. The exe Symbolic Link. The maps File. The root Symbolic Link. The statm File.

General System Info.

The /proc/cmdline File. The /proc/cpuinfo File. The /proc/devices File. The /proc/dma File. The /proc/file systems File. The /proc/interrupts File. The /proc/ioports File. The /proc/kcore File. The /proc/kmsg File. The /proc/ksyms File. The /proc/loadavg File. The /proc/locks File. The /proc/mdstat File. The /proc/meminfo File. The /proc/misc File. The /proc/modules File. The /proc/mounts File. The /proc/pci File. The /proc/rtc File. The /proc/stat File. The /proc/uptime File. The /proc/version File. The /proc/net Subdirectory. The /proc/scsi Subdirectory. The /proc/sys Subdirectory.

Changes to /proc in Upcoming Kernels. Summary.

16. Memory Management.

Reviewing C Memory Management.

Using the malloc Function. Using the calloc Function. Using the realloc Function. Using the free Function. Using the alloca Function.

Memory Mapping Files.

Using the mmap Function. Using the munmap Function. Using the msync Function. Using the mprotect Function. Locking Memory. Using the mremap Function. Implementing cat Using Memory Maps.

Finding and Fixing Memory Problems.

A Problem Child. Electric Fence.

Summary.

17. Interprocess Communication.

Pipes.

Opening and Closing Pipes. Reading and Writing Pipes. A Simpler Way.

FIFOs.

Understanding FIFOs. Creating a FIFO. Opening and Closing FIFOs. Reading and Writing FIFOs.

Introducing System V IPC.

Key Concepts of System V IPC. Problems with System V IPC. Linux and System V IPC.

Shared Memory.

Creating a Shared Memory Segment. Attaching a Shared Memory Segment.

Message Queues.

Creating and Opening a Queue. Writing a Message to a Queue. Reading Queued Messages. Removing Message Queues.

Semaphores.

Creating a Semaphore. Controlling and Removing Semaphores.

Summary.

18. Daemons.

Understanding Daemons. Creating a Daemon.

Function Calls. Handling Errors.

Communicating with a Daemon.

Reading a Configuration File. Adding Signal Handling to a Daemon.

Summary.

IV. NETWORK PROGRAMMING.

19. TCP/IP and Socket Programming.

A Definition of Sockets. Communication Domains. The Basics of Socket Programming.

Allocate and Initiate. Connection System Calls. Transfer Data. Close.

Client/Server Examples Using Sockets.

Server Example. Client Example. Running the Client and Server Examples. Running the Server Example Using a Web Browser as a Client.

A Simple Web Server and Sample Web Client.

Implementing a Simple Web Server. Implementing a Simple Web Client. Testing the Web Server and Web Client. Running the Simple Web Server Using Netscape Navigator as a Client.

Using Sockets with Other Programming Languages. Programming UNIX Domain Sockets with Perl. Tools for Monitoring Socket Activity. Summary.

20. UDP: The User Datagram Protocol.

Overview of UDP.

UDP Versus TCP. Advantages and Disadvantages of TCP. Advantages and Disadvantages of UDP. Choosing Which Protocol to Use.

Implementing a UDP-Based Application

Sending Data with UDP. Receiving UDP Data. Minimal Error Checking. Non-Blocking I/O.

Summary.

21. Multicast Sockets and Non-Blocking I/O.

Configuring Linux to Support Multicast IP. Rebuilding the Linux Kernel for Multicast IP Support. Sample Programs for Multicast IP Broadcast.

Broadcasting Data with Multicast IP. Creating a Client to Listen for Multicast IP Broadcasts. Running the Sample Multicast IP Programs.

Summary.

V. PROGRAMMING THE USER INTERFACE.

22. Terminal Control the Hard Way.

The Terminal Interface. Controlling Terminals.

Attribute Control Functions. Speed Control Functions. Line Control Functions. Process Control Functions.

Using the Terminal Interface. Changing Terminal Modes. Using Terminfo.

Terminfo Capabilities. Programming Terminfo. Working with Terminfo Capabilities.

Summary.

23. Getting Started with Ncurses.

A Short History of Ncurses. Compiling with Ncurses. Debugging Ncurses Programs. About Windows.

Ncurses Window Design. Ncurses Function Naming Conventions.

Initialization and Termination.

Ncurses Initialization Structures. Ncurses Termination. Illustrating Ncurses Initialization and Termination.

Input and Output.

Output Routines. Input Routines.

Color Routines. Window Management. Miscellaneous Utility Functions. Summary.

24. Advanced Ncurses Programming.

Additional Ncurses Capabilities.

Mouse Support. Menu Support. Form Support.

Interacting with Mice.

The Mouse API Overview. The Mouse Control Routines. Example Program.

Using Menus.

The Menu API Overview. The Menu Control Routines. Example Program.

Ncurses Forms.

The Forms API Overview. The Forms Management Routines. Example Program.

Summary.

25. X Windows Programming.

X Concepts. The Xlib API.

XOpenDisplay. XCreateSimpleWindow and XCreateWindow. Mapping and Unmapping Windows. Destroying Windows. Event Handling. Initializing Graphics Context and Fonts. Drawing in an X Window. A Sample Xlib Program.

The X Toolkit API.

Getting Started Using the X Toolkit. Setting Widget Arguments Using the X Toolkit.

XFree86.

DPMS-Display Power Management Signaling. DRI-Direct Render Interface. DGA-Direct Graphics Architecture. XV-X Video.

Summary.

26. Athena, Motif, and LessTif Widgets.

Using Athena Widgets.

The Athena Label Widget. The Athena Command Button Widget. The Athena List Widget. The Athena Text Widget. The Athena Simple Menu Widget.

Using Motif Widgets.

The Motif Label Widget. The Motif List Widget. The Motif Text Widget.

Writing a Custom Athena Widget.

Using the fetch_url.c File. Using the URL.h File. Using the URLP.h File. Using the URL.c File. Testing the URLWidget.

Using Both Athena and Motif in C++ Programs. Using a C++ Class Library for Athena Widgets.

The Component Class. The PaneWindow Class. The Label Class. The Button Class. The Text Class.

Summary.

27. GUI Programming Using GTK+.

Introduction to GTK+.

Handling Events in GTK+. A Short Sample Program Using GTK+. Miscellaneous GTK Widgets. GTK Container Widgets.

A GTK+ Program for Displaying XML Files.

A Short Introduction to XML. expat, James Clark's XML Parser. Implementing the GTK+ XML Display Program. Running the GTK XML Display Program.

A GUI Program Using the Notebook Widget.

Implementation of the Notebook Widget Sample Program. Implementing the Drawing Widget. Running the GTK Notebook Widget Sample Program.

Using GTK+ with Other Programming Languages.

Using GTK+ with C++. Using GTK+ with Perl. Using GTK+ with Python.

RAD Tools for GTK+. Summary.

28. GUI Programming Using Qt.

Event Handling by Overriding QWidget Class Methods.

Overview of the QWidget Class. Implementing the DrawWidget Class. Testing the DrawWidget.

Event Handling Using Qt Slots and Signals.

Deriving the StateLCDWidget Class. Using Signals and Slots. Running the Signal/Slot Example Program.

Implementing the XMLview Program with Qt.

SAX2: A Simple API for XML. DOM: The Document Object Model.

Summary.

29. 3D Graphics Using OpenGL and Mesa.

What You Need for This . Using OpenGL. Programming 3D Graphics.

orbits.c. Creating a Window for OpenGL Graphics and Initializing OpenGL. Creating Simple 3D Objects Using GLUT. Placing Objects in 3D Space Using x,y,z Coordinates. Rotating an Object About Any or All of the x-, y-, and z-Axes. Enabling the Use of Material Properties. Enabling Depth Tests. Handling Keyboard Events. Updating OpenGL Graphics for Animation Effects. Orbits Program Listing.

Texture Mapping.

Generating a Cube with Textured Sides. Creating Texture Maps. Cube Program Listing.

Summary.

VI. SPECIAL TOPICS.

30. Shell Programming with GNU Bash.

Why Bash? Bash Basics.

Wildcards. Brace Expansion. Special Characters.

Using Bash Variables. Using Bash Operators.

String Operators. Pattern-Matching Operators.

Flow Control.

Conditional Execution: if. Determinate Loops: for. Indeterminate Loops: while and until. Selection Structures: case and select.

Shell Functions. Input and Output.

I/O Redirectors. String I/O.

Command-Line Processing. Processes and Job Control.

Shell Signal-Handling. Using trap.

Summary.

31. Device Drivers.

Types of Drivers.

Statically Linked Kernel Device Drivers. Loadable Kernel Modules. Shared Libraries. Unprivileged Usermode Program. Privileged Usermode Programs. Daemons. Character Devices Versus Block Devices.

How to Construct the Hardware.

Understanding the Workings of a Stepper Motor. Standard or Bidirectional Parallel Port.

Setting Up Your Development Environment. Debugging Kernel-Level Drivers. Device Driver Internals.

Low-Level Port I/O. Accessing Memory Using DMA. Initiating Interrupts to Utilize Device Drivers. Layering of Device Drivers.

Simple Usermode Test Driver. Creating a Kernel Driver.

Reviewing the Source Code. Compiling the Driver. Using the Kernel Driver. Future Directions.

Other Sources of Information. Summary.

VII. FINISHING TOUCHES.

32. Package Management.

Understanding tar Files.

Creating tar Files. Updating tar Files. Listing the Contents of tar Files. Extracting Files from an Archive.

Understanding the install Command. Understanding the Red Hat Package Manager (RPM).

What Is RPM? Minimum Requirements. Configuring RPM. Controlling the Build: Using a spec File. Analyzing a spec File. Building the Package.

The File Hierarchy Standard. Summary.

33. Documentation.

Writing Man Pages.

Components of a Man Page. Sample Man Page. Using the groff Command. Linux Conventions.

Using DocBook.

What Is DocBook? DocBook Tags. A Sample DocBook Document. Generating Output.

Summary.

34. Licensing.

Introduction and Disclaimer. The MIT/X-Style License. The BSD-Style License. The Artistic License. The GNU General Public Licenses.

The GNU General Public License. The GNU Library General Public License.

The Open Source Definition. Summary.

Index.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020