Beginning Linux Programming, 2nd Edition
If you've installed Linux, or have access to a version of UNIX, you've probably gotten used to the environment and its configuration, but if you want to start programming, most Linux books leave you on your own. This book takes off where they stop, showing you how to make the most of the tools UNIX offers (which are included as standard with any distribution of Linux) and start programming UNIX for real.
Beginning Linux Programming, 2nd Edition, concentrates on C programming, looking at the GNU tools, and the UNIX C libraries, to teach you step by step how to write, build, and debug serious application code. Throughout the book, you develop a fully featured CD Database application, allowing you to see the theory of each new topic applied to a real application. As well as handling basic file operations, input and output and dealing with the way UNIX handles data, you discover such advanced topics as inter-process communication, networking, and using CGI scripting to build a Web interface — all the elements of client-server programming. You are also introduced the GTK+ and you find out how to build rich graphical user interfaces for X with GNOME. Finally, there's an introduction to device drivers, to give you a window into the way the Linux kernel itself works.
You'll also learn shell scripting for BASH, as well as two more powerful scripting languages — Tcl and Perl.
What does this book cover?
- The Perl language
- Programmming for GNOME(TM)
- POSIX(r) threads
- Kernel(r) programming
- Latest Linux kernel, current tools and C libraries
Who is this book for?
You need to be comfortable with the basics of using Linux, with a good working knowledge of how to use and configure your system. You should also know some simple C. If you're familiar with basic programming concepts, the working examples in the book will soon give you the confidence to explore Linux's C libraries.
You'll find the programming tools used in this book are included with virtually any Linux distribution, so this book is all you need to get started as a Linux programmer.
Chapter 1. Getting Started.
Chapter 2. Shell Programming.
Chapter 3. Working with Files.
Chapter 4. The UNIX Environment.
Chapter 5. Terminals.
Chapter 6. Curses.
Chapter 7. Data Management.
Chapter 8. Development Tools.
Chapter 9. Debugging.
Chapter 10. Processes and Signals.
Chapter 11. POSIX Threads.
Chapter 12. Inter-process Communication: Pipes.
Chapter 13. Semaphores, Message Queues and Shared Memory.
Chapter 14. Sockets.
Chapter 15. Tcl: Tool Command Language.
Chapter 16. Programming for X.
Chapter 17. Programming GNOME using GTK+.
Chapter 18. The Perl Programming Language.
Chapter 19. Programming for the Internet: HTML.
Chapter 20. Internet Programming 2: CGI.
Chapter 21. Device Drivers.
Appendix A. Portability.
Appendix B. FSF and the GNU Project.
Appendix C. Internet Resources.
Appendix D. Bibliography.
In terms of UNIX experience, Neil has used almost every flavor since Version 6, including Xenix, SCO flavors, Ultrix, BSD 4.2, Microport, System V, SunOS 4, Solaris and, of course, Linux. He's been a UNIX system administrator on-and-off since 1983. Neil is familiar with the internals of UNIX-like systems and was involved in the design and implementation of a intelligent communications controller for DEC Ultrix.
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 and Tcl, at home and at work. He also uses and recommends Linux for Internet connections, usua lly as a proxy caching server for Windows LANs and also as a file server to Windows 3.11/95 using SAMBA. He's sold a number of Internet firewall systems to UK companies (including Wrox!).
Most of Neil's 'home' projects were originally implemented in SCO UNIX, but they've been ported to Linux with little or no trouble. 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.
As the head of software and principal engineer at Camtec Electronics in the Eighties, Neil programmed in C and C++ for real-time embedded systems environments. Since then, he's worked on software development techniques and quality assurance both as a consultant in communications software development with Scientific Generics and as a software QA specialist for GEHE UK.
Richard Stones started programming at school, more years ago than he cares to remember, on a BBC micro, which with the help a few spare parts continued functioning for the next 15 years. He graduated from the University of Nottingham with an Electronic Engineering degree, by which time he had decided that software was more fun than hardware.
Over the years he has worked for a variety of companies, from the very small with just a few dozen employees, to multinationals, including the IT services giant EDS. Along the way he has worked on a wide range of different projects, from embedded real-time communications systems, through accounting systems, to large help desk systems with multi-gigabyte databases. Many of these projects have either been hosted on UNIX, or UNIX was the development environment. On one project the entire embedded software was developed and tested on Linux, and only ported to the target hardware and minimal real-time executive in the final stages. He is currently employed by the IT department of a pan-European wholesale and distribution company as a systems architect.
Rick’s first experience of a UNIX style operating system was on a PDP 11/23+, after which BSD4.2 on a VAX came as a pleasant improvement. After spells using UNIX System V.2, Xenix, SCO UNIX, AIX and a few others, he first met Linux back in the kernel .99 days, and has been a fan ever since.
A bit of a programming linguist, he has programmed systems in SL-1, a couple of assemblers, Fortran, Pascal, C, C++, Java, SQL and Perl. Under pressure he has also been known to admit to some familiarity with Visual Basic, but tries not to advertise this aberration.
Finally, both authors were co-authors of Instant UNIX (Wrox Press).
|Download source code tarball - gunzip, then tar -xvf to extract||432.93 KB||Click to Download|
Do you think you've discovered an error in this book? Please check the list of errata below to see if we've already addressed the error. If not, please submit the error via our Errata Form. We will attempt to verify your error; if you're right, we will post a correction below.
|0||'Gnome clock' code - missing brackets around the else statement
Page 665, point no. 12, 'else' section of code - braces missing.
|2||34||file first.sh mstakenly named as 'first' in code bundle
The script first.sh is provided in the code bundle available for download, with the name 'first'. It should be renamed to 'first.sh'.
|2||40||File try_variables named as try_var in code bundle
The file try_variables is provided with the name try_var in the code bundle avaible online for download.
|128||ISO/ANSI C states that main() must return int
|137||Current Date and Time / Code gmtime.c
The current year, as returned by the code in the program, is the number of years past the year 1900. This looks strange for years past 2000. Adding 1900 to the result gives a more comprehendible result, like 2002, for that year, instead of 102, as would be returned by the code in the book.
|141||strftime: complier warning
Patch for code section strftime.c (required on Linux, where the the prototype for strptime() is not seen). Addition made to code - #define _XOPEN_SOURCE Without this, compling on Linux would produce the following warning: assignment makes pointer from integer without a cast
In the exec function to start the ps program, the line:
|367||missing piece of code
The code in step number 2 should start with the following (before pid_t pid;)
|380|| Spelling Errors
|389||Change in the text
The first sentence (4th prragraph) is "It is to overlook subtle timing faults". It should be "A common source of problem is to overlook subtle timing faults"