27,99 €
Beginning Linux Programming, Fourth Edition continues its unique approach to teaching UNIX programming in a simple and structured way on the Linux platform. Through the use of detailed and realistic examples, students learn by doing, and are able to move from being a Linux beginner to creating custom applications in Linux. The book introduces fundamental concepts beginning with the basics of writing Unix programs in C, and including material on basic system calls, file I/O, interprocess communication (for getting programs to work together), and shell programming. Parallel to this, the book introduces the toolkits and libraries for working with user interfaces, from simpler terminal mode applications to X and GTK+ for graphical user interfaces. Advanced topics are covered in detail such as processes, pipes, semaphores, socket programming, using MySQL, writing applications for the GNOME or the KDE desktop, writing device drivers, POSIX Threads, and kernel programming for the latest Linux Kernel.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 1173
Veröffentlichungsjahr: 2011
Table of Contents
Cover
Title Page
Copyright
About the Authors
Credits
Acknowledgments
Foreword
Introduction
Who’s This Book For?
What’s Covered in the Book
What You Need to Use This Book
Source Code
Conventions
Errata
p2p.wrox.com
Chapter 1: Getting Started
An Introduction to UNIX, Linux, and GNU
Programming Linux
Getting Help
Summary
Chapter 2: Shell Programming
Why Program with a Shell?
A Bit of Philosophy
What Is a Shell?
Pipes and Redirection
The Shell as a Programming Language
Shell Syntax
Going Graphical — The dialog Utility
Putting It All Together
Summary
Chapter 3: Working with Files
Linux File Structure
System Calls and Device Drivers
Library Functions
Low-Level File Access
The Standard I/O Library
Formatted Input and Output
File and Directory Maintenance
Scanning Directories
Errors
The /proc File System
Advanced Topics: fcntl and mmap
Summary
Chapter 4: The Linux Environment
Program Arguments
Environment Variables
Time and Date
Temporary Files
User Information
Host Information
Logging
Resources and Limits
Summary
Chapter 5: Terminals
Reading from and Writing to the Terminal
Talking to the Terminal
The Terminal Driver and the General Terminal Interface
The termios Structure
Terminal Output
Detecting Keystrokes
Summary
Chapter 6: Managing Text-Based Screens with curses
Compiling with curses
Curses Terminology and Concepts
The Screen
The Keyboard
Windows
Subwindows
The Keypad
Using Color
Pads
The CD Collection Application
Summary
Chapter 7: Data Management
Managing Memory
File Locking
Databases
The CD Application
Summary
Chapter 8: MySQL
Installation
MySQL Administration
Accessing MySQL Data from C
The CD Database Application
Summary
Chapter 9: Development Tools
Problems of Multiple Source Files
The make Command and Makefiles
Source Code Control
Writing a Manual Page
Distributing Software
RPM Packages
Other Package Formats
Development Environments
Summary
Chapter 10: Debugging
Types of Errors
General Debugging Techniques
Debugging with gdb
More Debugging Tools
Assertions
Memory Debugging
Summary
Chapter 11: Processes and Signals
What Is a Process?
Process Structure
Starting New Processes
Signals
Summary
Chapter 12: POSIX Threads
What Is a Thread?
Advantages and Drawbacks of Threads
A First Threads Program
Simultaneous Execution
Synchronization
Thread Attributes
Canceling a Thread
Threads in Abundance
Summary
Chapter 13: Inter-Process Communication: Pipes
What Is a Pipe?
Process Pipes
Sending Output to popen
The Pipe Call
Parent and Child Processes
Named Pipes: FIFOs
The CD Database Application
Summary
Chapter 14: Semaphores, Shared Memory, and Message Queues
Semaphores
Shared Memory
Message Queues
The CD Database Application
IPC Status Commands
Summary
Chapter 15: Sockets
What Is a Socket?
Socket Connections
Network Information
Multiple Clients
Datagrams
Summary
Chapter 16: Programming GNOME Using GTK+
Introducing X
Introducing GTK+
Events, Signals, and Callbacks
Packing Box Widgets
GTK+ Widgets
GNOME Widgets
GNOME Menus
Dialogs
CD Database Application
Summary
Chapter 17: Programming KDE Using Qt
Introducing KDE and Qt
Installing Qt
Signals and Slots
Qt Widgets
Dialogs
Menus and Toolbars with KDE
CD Database Application Using KDE/Qt
Summary
Chapter 18: Standards for Linux
The C Programming Language
Interfaces and the Linux Standards Base
The Filesystem Hierarchy Standard
Further Reading about Standards
Summary
Index
Advertisement
Wiley End User License Agreement
Beginning Linux® Programming, 4th Edition
Published byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com
Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-14762-7
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Library of Congress Cataloging-in-Publication Data is available from the publisher.
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Linux is a trademark of Linus Torvalds. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
About the Authors
Neil Matthew has been interested in and has programmed computers since 1974. A mathematics graduate from the University of Nottingham, Neil is just plain keen on programming languages and likes to explore new ways of solving computing problems. He’s written systems to program in BCPL, FP (Functional Programming), Lisp, Prolog, and a structured BASIC. He even wrote a 6502 microprocessor emulator to run BBC microcomputer programs on UNIX systems.
In terms of UNIX experience, Neil has used almost every flavor since the late 1970s, including BSD UNIX, AT&T System V, Sun Solaris, IBM AIX, many others, and of course Linux. He can claim to have been using Linux since August 1993 when he acquired a floppy disk distribution of Soft Landing (SLS) from Canada, with kernel version 0.99.11. He’s used Linux-based computers for hacking C, C++, Icon, Prolog, Tcl, and Java at home and at work.
All of Neil’s “home” projects are developed using Linux. He says Linux is much easier because it supports quite a lot of features from other systems, so that both BSD- and System V-targeted programs will generally compile with little or no change.
Neil is currently working as an Enterprise Architect specializing in IT strategy at Celesio AG. He has a background in technical consultancy, software development techniques, and quality assurance. Neil has also programmed in C and C++ for real-time embedded systems.
Neil is married to Christine and has two children, Alexandra and Adrian. He lives in a converted barn in Northamptonshire, England. His interests include solving puzzles by computer, music, science fiction, squash, mountain biking, and not doing it yourself.
Rick Stones started programming at school (more years ago than he cares to remember) on a 6502-powered BBC micro, which, with the help of a few spare parts, continued to function for the next 15 years. He graduated from Nottingham University with a degree in Electronic Engineering, but decided software was more fun.
Over the years he has worked for a variety of companies, from the very small with just a dozen employees, to the very large, including the IT services giant EDS. Along the way he has worked on a range of projects, from real-time communications to accounting systems, to very large help desk systems. He is currently working as an IT architect, acting as a technical authority on various major projects for a large pan-European company.
A bit of a programming linguist, he has programmed in various assemblers, a rather neat proprietary telecommunications language called SL-1, some FORTRAN, Pascal, Perl, SQL, and smidgeons of Python and C++, as well as C. (Under duress he even admits that he was once reasonably proficient in Visual Basic, but tries not to advertise this aberration.)
Rick lives in a village in Leicestershire, England, with his wife Ann, children Jennifer and Andrew, and a cat. Outside work his main interests are classical music, especially early religious music, and photography, and he does his best to find time for some piano practice.
Credits
Acquisitions Editor
Jenny Watson
Development Editor
Sara Shlaer
Technical Editor
Timothy Boronczyk
Production Editor
William A. Barton
Copy Editor
Kim Cofer
Editorial Manager
Mary Beth Wakefield
Production Manager
Tim Tate
Vice President and Executive Group Publisher
Richard Swadley
Vice President and Executive Publisher
Joseph B. Wikert
Project Coordinator, Cover
Adrienne Martinez
Graphics and Production Specialists
Mike Park, Happenstance-Type-O-Rama
Craig Woods, Happenstance-Type-O-Rama
Proofreader
Amy McCarthy, Word One
Indexer
Johnna VanHoose Dinse
Anniversary Logo Design
Richard Pacifico
Acknowledgments
The authors would like to record their thanks to the many people who helped to make this book possible.
Neil would like to thank his wife, Christine, for her understanding and children Alex and Adrian for not complaining too loudly at Dad spending so long in The Den writing.
Rick would like to thank his wife, Ann, and their children, Jennifer and Andrew, for their very considerable patience during the evenings and weekends while Dad was yet again “doing book work.”
As for the publishing team, we’d like to thank the folks at Wiley who helped us get this fourth edition into print. Thanks to Carol Long for getting the process started and sorting out the contracts, and especially to Sara Shlaer for her exceptional editing work and Timothy Boronczyk for his excellent technical reviews. We also wish to thank Jenny Watson for chasing down all those odd bits of extras and generally guiding the book through the administrative layers, Bill Barton for ensuring proper organization and presentation, and Kim Cofer for a thorough copyedit. We are very grateful also to Eric Foster-Johnson for his fantastic work on Chapters 16 and 17. We can say that this is a better book than it would have been without the efforts of all of you.
We would also like to thank our employers, Scientific Generics, Mobicom, and Celesio for their support during the production of all four editions of this book.
Finally we would also like to pay homage to two important motivators who have helped make this book possible. Firstly, Richard Stallman for the excellent GNU tools and the idea of a free software environment, which is now a reality with GNU/Linux, and secondly, Linus Torvalds for starting and continuing to inspire the co-operative development that gives us the ever-improving Linux kernel.
Foreword
All computer programmers have their own piles of notes and scribbles. They have their code examples saved from the past heroic dive into the manuals or from Usenet, where sometimes even fools fear to follow. (The other body of opinion is that fools all get free Usenet access and use it nonstop.) It is therefore perhaps strange that so few books follow such a style. In the online world there are a lot of short, to-the-point documents about specific areas of programming and administration. The Linux documentation project released a whole pile of documents covering everything from installing Linux and Windows on the same machine to wiring your coffee machine to Linux. Seriously. Take a look at The Linux Documentation Project on http://www.tldp.org.
The book world, on the other hand, seems to consist mostly of either learned tomes, detailed and very complete works that you don’t have time to read, or books for complete beginners that you buy for friends as a joke. There are very few books that try to cover the basics of a lot of useful areas. This book is one of them, a compendium of those programmers’ notes and scribbles, deciphered (try reading a programmer’s handwriting), edited, and brought together coherently as a book.
This edition of Beginning Linux Programming has been reviewed and updated to reflect today’s Linux developments.
—Alan Cox
Introduction
Welcome to Beginning Linux Programming, 4th Edition, an easy-to-use guide to developing programs for Linux and other UNIX-style operating systems.
In this book we aim to give you an introduction to a wide variety of topics important to you as a developer using Linux. The word Beginning in the title refers more to the content than to your skill level. We’ve structured the book to help you learn more about what Linux has to offer, however much experience you have already. Linux programming is a large field and we aim to cover enough about a wide range of topics to give you a good “beginning” in each subject.
Who’s This Book For?
If you’re a programmer who wishes to get up to speed with the facilities that Linux (or UNIX) offers software developers, to maximize your programming time and your application’s use of the Linux system, you’ve picked up the right book. Clear explanations and a tried and tested step-by-step approach will help you progress rapidly and pick up all the key techniques.
We assume you have some experience in C and/or C++ programming, perhaps in Windows or some other system, but we try to keep the book’s examples simple so that you don’t need to be an expert C coder to follow this book. Where direct comparisons exist between Linux programming and C/C++ programming, these are indicated in the text.
Watch out if you’re totally new to Linux. This isn’t a book on installing or configuring Linux. If you want to learn more about administering a Linux system, you may wish to look at some complementary books such as Linux Bible 2007 Edition, by Christopher Negus (Wiley, ISBN 978-0470082799).
Because it aims to be a tutorial guide to the various tools and sets of functions/libraries available to you on most Linux systems as well as a handy reference you can return to, this book is unique in its straightforward approach, comprehensive coverage, and extensive examples.
What’s Covered in the Book
The book has a number of aims:
To teach the use of the standard Linux C libraries and other facilities as specified by the various Linux and UNIX standards.To show how to make the most of the standard Linux development tools.To give a concise introduction to data storage under Linux using both the DBM and MySQL database systems.To show how to build graphical user interfaces for the X Window System. We will use both the GTK (the basis of the GNOME environment) and Qt (the basis of the KDE environment) libraries.To encourage and enable you to develop your own real-world applications.As we cover these topics, we introduce programming theory and then illustrate it with appropriate examples and a clear explanation. In this way you can learn quickly on a first read and look back over things to brush up on all the essential elements if you need to.
Though the small examples are designed mainly to illustrate a set of functions or some new theory in action, throughout the book lies a larger sample project: a simple database application for recording audio CD details. As your knowledge expands, you can develop, re-implement, and extend the project to your heart’s content. That said, however, the CD application doesn’t dominate any chapter, so you can skip it if you want to, but we feel that it provides additional useful, in-depth examples of the techniques that we discuss. It certainly provides an ideal way to illustrate each of the more advanced topics as they are introduced. Our first discussion of this application occurs at the end of Chapter 2 and shows how a fairly large shell script is organized, how the shell deals with user input, and how it can construct menus and store and search data.
After recapping the basic concepts of compiling programs, linking to libraries, and accessing the online manuals, you will take a sojourn into shells. You then move into C programming, where we cover working with files, getting information from the Linux environment, dealing with terminal input and output, and the curses library (which makes interactive input and output more tractable). You’re then ready to tackle re-implementing the CD application in C. The application design remains the same, but the code uses the curses library for a screen-based user interface.
From there, we cover data management. Meeting the dbm database library is sufficient cause for us to re-implement the application, but this time with a design that will re-emerge in some later chapters. In a later chapter we look at how the data could be stored in a relational database using MySQL, and we also reuse this data storage technique later in the chapter, so you can see how the techniques compare. The size of these recent applications means that we then need to deal with such nuts-and-bolts issues as debugging, source code control, software distribution, and makefiles.
You will also look at how different Linux processes can communicate, using a variety of techniques, and at how Linux programs can use sockets to support TCP/IP networking to different machines, including the issues of talking to machines that use different processor architectures.
After getting the foundations of Linux programming in place, we cover the creation of graphical programs. We do this over two chapters, looking first at the GTK+ toolkit, which underlies the GNOME environment, and then at the Qt toolkit, which underlies the KDE environment.
We finish off with a brief look at the standards that keep Linux systems from different vendors similar enough that we can move between them easily and write programs that will work on different distributions of Linux.
As you’d expect, there’s a fair bit more in between, but we hope that this gives you a good idea of the material we’ll be discussing.
What You Need to Use This Book
In this book, we’ll give you a taste of programming for Linux. To help you get the most from the chapters, you should try out the examples as you read. These also provide a good base for experimentation and will hopefully inspire you to create programs of your own. We hope you will read this book in conjunction with experimenting on your own Linux installation.
Linux is available for many different systems. Its adaptability is such that enterprising souls have persuaded it to run in one form or another on just about anything with a processor in it! Examples include systems based on the Alpha, ARM, IBM Cell, Itanium, PA-RISC, PowerPC, SPARC, SuperH, and 68k CPUs as well as the various x86-class processors, in both 32- and 64-bit versions.
We wrote this book and developed the examples on two Linux systems with different specifications, so we’re confident that if you can run Linux, you can make good use of this book. Furthermore, we tested the code on other versions of Linux during the book’s technical review.
To develop this book we primarily used x86-based systems, but very little of what we cover is x86 specific. Although it is possible to run Linux on a 486 with 8MB RAM, to run a modern Linux distribution successfully and follow the examples in this book, we recommend that you pick a recent version of one of the more popular Linux distributions such as Fedora, openSUSE, or Ubuntu and check the hardware recommendations they give.
As for software requirements, we suggest that you use a recent version of your preferred Linux distribution and apply the current set of updates, which most vendors make available online by way of automated updates, to keep your system current and up-to-date with the latest bug fixes. Linux and the GNU toolset are released under the GNU General Public License (GPL). Most other components of a typical Linux distribution use either the GPL or one of the many other Open Source licenses, and this means they have certain properties, one of which is freedom. They will always have the source code available, and no one can take that freedom away. See http://www.gnu.org/licenses/ for more details of the GPL, and http://www.opensource.org/ for more details of the definition of Open Source and the different licenses in use. With GNU/Linux, you will always have the option of support — either doing it yourself with the source code, hiring someone else, or going to one of the many vendors offering pay-for support.
Source Code
As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All of the source code used in this book is available for download at http://www.wrox.com. Once at the site, simply locate the book’s title (either by using the Search box or by using one of the title lists) and click the Download Code link on the book’s detail page to obtain all the source code for the book.
Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-0-470-14762-7.
Once you download the code, just decompress it with your favorite compression tool. Alternatively, you can go to the main Wrox code download page at http://www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.
A Note on the Code Downloads
We have tried to provide example programs and code snippets that best illustrate the concepts being discussed in the text. Please note that, in order to make the new functionality being introduced as clear as possible, we have taken one or two liberties with coding style.
In particular, we do not always check that the return results from every function we call are what we expect. In production code for real applications we would certainly do this check, and you too should adopt a rigorous approach toward error handling. (We discuss some of the ways that errors can be caught and handled in Chapter 3.)
The GNU General Public License
The source code in the book is made available under the terms of the GNU General Public License version 2, http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. The following permission statement applies to all the source code available in this book:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conventions
To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book:
Boxes like this one hold important, not-to-be-forgotten, mission-critical information that is directly relevant to the surrounding text.
Tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.
When we introduce them, we highlight important words in italics. Characters we want you to type are in bold font. We show keyboard strokes like this: Ctrl+A.
We present code and terminal sessions in three different ways:
$ who
root tty1 Sep 10 16:12
rick tty2 Sep 10 16:10
When the command line is shown, it’s in the style at the top of the code, whereas output is in the regular style. The $ is the prompt (if the superuser is required for the command, the prompt will be a # instead) and the bold text is what you type in and press Enter (or Return) to execute. Any text following that in the same font but in non-bold is the output of the bolded command. In the preceding example you type in the command who, and you see the output below the command.
Prototypes of Linux-defined functions and structures are shown in bold as follows:
#include <stdio.h>
int printf (const char *format, ...);
In our code examples, the code foreground style shows new, important material, such as
/* This is what new, important, and pertinent code looks like. */
whereas code that looks like this (code background style) is less important:
/* This is what code that has been seen before looks like. */
And often when a program is added to throughout a chapter, code that is added later is in foreground style first and background style later. For example, a new program would look like this:
/* Code example */
/* That ends here. */
And if we add to that program later in the chapter, it looks like this instead:
/* Code example */
/* New code added */
/* on these lines */
/* That ends here. */
The last convention we’ll mention is that we presage example code with a “Try It Out” heading that aims to split the code up where it’s helpful, highlight the component parts, and show the progression of the application. When it’s important, we also follow the code with a “How It Works” section to explain any salient points of the code in relation to previous theory. We find these two conventions help break up the more formidable code listings into palatable morsels.
Errata
We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save another reader hours of frustration and at the same time you will be helping us provide even higher quality information.
To find the errata page for this book, go to http://www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all errata that has been submitted for this book and posted by Wrox editors. A complete book list including links to each book’s errata is also available at www.wrox.com/misc-pages/booklist.shtml.
If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We’ll check the information and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the book.
p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.
At http://p2p.wrox.com you will find a number of different forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:
1. Go to p2p.wrox.com and click the Register link.
2. Read the terms of use and click Agree.
3. Complete the required information to join as well as any optional information you wish to provide and click Submit.
4. You will receive an e-mail with information describing how to verify your account and complete the joining process.
You can read messages in the forums without joining P2P but in order to post your own messages, you must join.
Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.
Chapter 1
Getting Started
In this chapter, you discover what Linux is and how it relates to its inspiration, UNIX. You take a guided tour of the facilities provided by a Linux development system, and write and run your first program. Along the way, you’ll be looking at
UNIX, Linux, and GNUPrograms and programming languages for LinuxHow to locate development resourcesStatic and shared librariesThe UNIX philosophyAn Introduction to UNIX, Linux, and GNU
In recent years Linux has become a phenomenon. Hardly a day goes by without Linux cropping up in the media in some way. We’ve lost count of the number of applications that have been made available on Linux and the number of organizations that have adopted it, including some government departments and city administrations. Major hardware vendors like IBM and Dell now support Linux, and major software vendors like Oracle support their software running on Linux. Linux truly has become a viable operating system, especially in the server market.
Linux owes its success to systems and applications that preceded it: UNIX and GNU software. This section looks at how Linux came to be and what its roots are.
What Is UNIX?
The UNIX operating system was originally developed at Bell Laboratories, once part of the telecommunications giant AT&T. Designed in the 1970s for Digital Equipment PDP computers, UNIX has become a very popular multiuser, multitasking operating system for a wide variety of hardware platforms, from PC workstations to multiprocessor servers and supercomputers.
A Brief History of UNIX
Strictly, UNIX is a trademark administered by The Open Group, and it refers to a computer operating system that conforms to a particular specification. This specification, known as The Single UNIX Specification, defines the names of, interfaces to, and behaviors of all mandatory UNIX operating system functions. The specification is largely a superset of an earlier series of specifications, the P1003, or POSIX (Portable Operating System Interface) specifications, developed by the IEEE (Institute of Electrical and Electronic Engineers).
Many UNIX-like systems are available commercially, such as IBM’s AIX, HP’s HP-UX, and Sun’s Solaris. Some have been made available for free, such as FreeBSD and Linux. Only a few systems currently conform to The Open Group specification, which allows them to be marketed with the name UNIX.
In the past, compatibility among different UNIX systems has been a real problem, although POSIX was a great help in this respect. These days, by following a few simple rules it is possible to create applications that will run on all UNIX and UNIX-like systems. You can find more details on Linux and UNIX standards in Chapter 18.
UNIX Philosophy
In the following chapters we hope to convey a flavor of Linux (and therefore UNIX) programming. Although programming in C is in many ways the same whatever the platform, UNIX and Linux developers have a special view of program and system development.
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!