Linux Application Development
The overall structure has the book 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 lightweight except for the one on memory debugging tools. Here the authors dive into the common issues of buffer overflows and underruns, and the various utilities you can use to discover them. Not only the glibc features mcheck(), MALLOC_CHECK_ and mtrace(), but the memory profiler (mpr), Valgrind, and Electric Fence are discussed in enough detail to be useful.
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. Each chapter covers its topic in detail, and many code examples are given to clarify the concepts. 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. I will discuss them as I see the relationships.
Chapter 10 covers the Unix/Linux process model. Signals, job control, processes and threads are explained in detail. The authors also describe the 'gotcha's involved with setuid and setgid programs. The chapter ends with the first iteration of a sample shell program, ladsh. This shell is expanded as the book progresses to explain newer concepts. This topic should be followed by chapter 15 (Job Control), which goes into job control, including how to stop and start processes, move jobs between the foreground and the background, and handle job control signals.
Skipping back, chapter 11 introduces the file handling metaphor and how it relates to files, pipes, directories, devices, links, and sockets. It also explains inodes, file permissions, file descriptors, and the read/write/seek system calls. Chapter 13 expands on chapter 11 by discussing the advanced topics of multiple file handling, memory-mapped files, file locking, and scatter reads/gather writes. The next chapter goes over directory operations, such as handling the working directory, file name globbing, walking trees and directory change notification.
Signal Processing (chapter 12) discusses simple interprocess communication including signals and handlers. It describes the Linux and POSIX Signal API, real-time signals, and how to transmit data with a signal. Remote interprocess communication occurs over sockets. Chapter 17, Networking with Sockets, shows how to use the socket API, which can be used for IP, IPX, AppleTalk and Unix domain sockets. Michael and Erik show how to write a client and server, how to handle name resolution, the differences between session (e.g. TCP) and datagram (e.g. UDP) communications, and finish with an example tftp server.
Obviously, many programs need to interact with the user, and that's where chapters 16, 20, and 21 come into play. Chapter 16 talks about terminals (tty) and pseudo terminals (ptty) and how to program them. The POSIX termios interface is discussed in depth. Chapter 20 gives you tools to manipulate virtual consoles, which create the abstraction needed to multiplex different sessions on the same keyboard, video, and mouse. The following chapter talks about the Linux Console including text-based screen-drawing with S-Lang and curses, the terminal capabilities (termcap) and terminal information (terminfo) databases, ANSI Escape sequences, as well as direct screen writing.
Chapters 18 covers basic system calls for time/date representation and formatting and timer usage, and chapter 19 covers pseudo-random number generation and its use in cryptography. Finally, part 3 wraps up with chapter 22 discussing how to write secure programs. Common exploits such as buffer overflows and unauthorized directory traversals, and the ways you can prevent them (length checking and chroot, for example) only scratch the surface. The authors recognize this is just an introduction and refer you to another book to fill in the blanks.
The final part of the book covers the various development libraries commonly available to the programmer. The six chapters cover a wide range of topics. Chapter 23 covers the ins and outs of string handling, including processing regular expressions. A simple grep program demonstrates the ideas. Using S-Lang to handle the terminal is the main interest of the next chapter. Basic input/output handling, and line drawing using text characters seem mundane in this day and age of GUI interfaces, but they have their place. Check out a Red Hat install to see what I mean.
Chapter 25 discusses database interfaces. While gdbm and Berkeley db are better known, Michael and Erik chose to focus on qdbm, which is licensed under the LGPL, making it more attractive. Linux programmers are used to typing in commands with all of their options. Getopt and getopt_long are the standard for processing those options, but popt is detailed due to its extended capabilities, such as nested options which allow libraries to define options for them to handle which the main program can effectively ignore.
The final two chapters cover dynamic loading of shared objects (as opposed to shared libraries) with the advantages that provides, and user identification and authentication, covering id-to-name translation, and Pluggable Authentication Modules (PAM). As usual, example code shows clearly how to use the interfaces.
I know this review is lengthier than usual, but this book has so much packed within its covers, I didn't want to give short shrift to any part of it. When programming, one needs a number of reference books at hand, and Linux Application Development should definitely be one of the handiest. Just about every aspect of how to interface to Linux from your application program is covered, and the numerous code snippets and examples keep things understandable. An extremely useful book such as this deserves a high ranking. 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 9 out of 10.
You can purchase Linux Application Development, 2nd Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Let me guess... emacs is covered in 74 of those pages and the vi page simply reads: Use emacs.
Why so many books cover topics which are described in manuals (I mean man's for linux) ? In my opinion a good book should not repeat those things but describe only structure and philosophy of topic. For further reference you should then read mans.
You call this a review? It's more like a table of contents. "This book covers X, Y, and Z." How's the writing quality? How good are the examples?
It talks about programming in C and C++ and is therefore insecure.
I'm a big tall mofo.
Just FWIW, I reviewed LAD2 in LWN about a month ago.
Jonathan Corbet, LWN.net
"Finally, part 3 wraps up with chapter 22 discussing how to write secure programs" How come the "secure" part of coding, perhaps one of the most important parts of coding, is always last in the book?
Earn a free iRiver
Because mans suck.
Really, before you mod me down, do you really believe that the majority of mans provide enough information for people just learning the tool?
Socialism: A feeling of discontent and resentment caused by a desire for the possessions or qualities of another.
...out of the Stargate or something.
NO! It is the FARGATE! It is not some other kind of gate from a movie or TV show that I've never seen! Notice that it has a wheelchair and a pink mohawk? We're not getting sued!
No, it is a Fargate! From the makers of Findependence Day!
(Sorry, obligatory ATHF remark)
It's a Fargate. Not a Stargate like from that movie, or the popular syndicated TV series.
Its not what it is, its something else.
There is one proverb in Russian "Let we live some time and see how is it!" - (sorry for poor translation of "Pojivem pospotrim")
You see "OSTG" earned some money for paied article, publishers will also earn something, even autors will get some money... if they are realy good life will show and we will have 2nd edition etc.
While such things as pipes, regular expressions, setting date & time etc. are all fundamentals of any kind of programming, it seems a more apt name for the book would be Linux Command-Line Application Development, or Linux Daemon Development.
"Writing Linux applications is not a simple endeavor. The Linux operating system provides a sophisticated framework for running programs, and learning how to take advantage of that framework requires some research." Oh boy, doesn't that just sound like fun.
Maybe the author feels that in order to get the most out of a chapter about writing secture programs you first need a good base in the things discussed in earlier chapters.
The first edition carries a dedication by Mr. Johnson, which reads "To the memory of my grandmother, Eleanor Johnson, who taught faith in God by example. . ." Proselytization is repugnant wherever it is encountered; between the covers of a science text it is inexcusable.
There's hundreds of programming books released all the time. Why is Slashdot interested in this particular one?
--
Earn a free iRiver
Earn a free iRiver
I ended up finding what I needed in the man pages for various memory-related system calls, and in the very good but older Interprocess Communications in Unix by John Gray.
For the same reason "Hello World" isn't written as a multi-threaded client/server based program.
You gotta understand the concepts before you understand the dangers associated with them.
Compare a book describing the "sophisticated APIs" with a "Visual Basic for dummies".
C'mon guys, where's the RAD for Linux?
NO, It's called the FARGATE. Get it straight!
The security section is exactly where it should be. You have to understand a system before you can secure it. If you try to secure it before you understand it, you will never make it secure. You a Troll?
My guess is hes an MCSE =)
i thought the apt-get faerie just creates them out of thin air...
pr0n - keeping monitor glass spotless since 1981.
You realise google will only cache posts at +1 due to slashdot's default settings?
Please, do not rely upon the "Linux Man Page Howto". For example, in the "few thoughts about documentation", the following guidelines are given:
Documentation must be accessible.
Documentation must be reliable and accurate.
What about "Documentation must be cryptic!!!" Face it - if you're going to go through the trouble of writing a man page, would you rather have your target audience read it once, or tens and hundreds of times!
.. gives a good overview of the subject
http://www.faqs.org/docs/artu/
In this world nothing is certain but death, taxes and flawed car analogies.
I had (or maybe I still have) a plan of writing web-based introduction to Linux programming. Related to IPC, I am wandering, which areas are really important? For instance, pipes are nice, but I used them only for testing, never in real-life app. Basically, I prefer signals, sempaphores and shared memory. I have never used even real-time signals, no matter that they are really better, I had no real reason to use them instead of standard ones.
I would like to know, what do you use in your apps?
No sig today.
That's cheaper than Rat Had's Lunix. Where can I get 10,000,000 licenses?
Based on how Slashdot readers have responded to my other comments today, I'm fairly sure I'm going to get some hate mail for this, but here goes anyway.
It seems to me that now, in 2005, all the useful command-line programs have been written. There are no more useful command-line programs out there to write. So why does a book like this even bother discussing the writing of command-line programs? Isn't it a big waste of time?
The way I see it, the useful software that exists right now falls into three broad categories: embedded software, server software and applications. Embedded software is stuff like aircraft avionics. There's no user involved. Server software includes stuff like Oracle and WebObjects. There's a user involved, but not directly. And applications are what we all use on our desktops and laptops.
Nowhere in there is there room for a command-line program that hasn't yet been written. All the basic tools for dealing with files and stuff have already been perfected (at least to the extent that they're going to be).
So why even waste any energy on it? Isn't it kind of like having a chapter at the beginning that discusses the right way to encode your program onto punch-cards?
..ade of Whatever Wondrous Bits and Bobs from Around The Globe You Could Find.
.. and most of them are still running, doing the specific job they were built for. custom applications abound!
.. distro war or none, linux is involved in running a lot of the empire of man, i would say ..]
as a linux application developer, 'linux' to me represents a wonderous toolset of marvel.
much as it may pain to state the obvious, the joy to be had in building your own entire OS; literally choosing only the bits you need for your application, cannot be under-valued.
weird to think of it (its gone so fast) but for 10 years i've been designing and building custom linux systems for a living
[all the linux press/hooplah these days does tend to overlook the customer-built installs of linux, i think
; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
That would be an interesting programming challenge: Write the most pointlessly complicated "Hello World" program. Not to make "Hello World" appear in fancy graphics with special effects or whatnot - just your basic terminal-based "Hello World" :)
:)
I'd probably approach it using shared memory, a cron job, and packets with low TTLs.
Dear Lord: One of your creatures may be hurt tonight. Please let it be the other creature.
He can only be killed by the bone sabre of Zuma Kali!
LilMikey.com... I'll stop doing it when you sto
Here are my links:
The global economy is a great thing until you feel it locally.
wtf does your retarded comment have to do with the parent post?
Does it make any sense to say all the useful GUI programs have been written? The GUI is just a method of interaction. Having to design for a command-line interface encourages model-view-controller design. IMO, a proper application can be run interactively, through config files and a command-line, or as an API from another program.
--
Long-term effects of Bush deficits
You're either a troll or a dimwit.
That's odd, I spend a LOT of time writing code that ends up in command-line programs. I wonder how I do that, given that you say there's no room for such a thing.
Just take a look on the open-source project where I write the most code, mjpegtools. It's the open-source MPEG2-video (i.e. DVD) creation package. You'll have to look at the CVS version to see my latest contribution, though; it's not officially released yet. It's called y4mdenoise; you can browse the CVS version here. It's a new temporal noise-reduction tool for digital video, that does such a good job of inferring clear images from several noisy examples of them, that it can make a videotape look like it came from a LaserDisc. No kidding.
You remind me of the head of the U.S. Patent Office in 1899, who said that everything that can be invented has been. I wish people like you would get the heck out of the way of people like me.
"Once we've identified and embraced our sickness, we'll have strength...and that's when we get dangerous." - John Waters
Embedded does not mean that there is no user, rather it just means that the software is part of a device. That device could be a cable box, a PVR, a radar dislay/interface system in an aircraft, the music browsing interface on your digital music player, or any of dozens of other devices. All of these are embedded systems.
(from someone who does embedded software development).
My other first post is car post.
I found the book an excellent introduction to... well, Linux Application Development.
To become productive on a platform, you need to know what that platform is fundamentally capable of, and the APIs that provide access to that functionality. And, as a programmer, I find a quick and well-ordered tour through key APIs the best way to get a handle on both before diving in to some serious development.
Now man pages become useful - now that you know what you _can_ do, have a rough idea of the platform's design philosophy and capabilities, and so you know where to start looking with man.
I bought this book a few months ago and its quite nice. It goes through all the system calls and libraries that most Linux Programmers use or will ever need to use. Networking, Processes, Files, the works. Definitely a good resource if you need to reference things as well later on.
As I said I already own it, and I though it was so good that I bought it as presents for some of my friend. The first edition is handy and I keep it on my desk as a reference when man pages just don't cut it.
I also own an electronic version so I don't have to take it with me when I have to go out on a job.
If the second edition is as good as the first then I'd advise everybody to get a copy.
'I am become Shiva, destroyer of worlds'
the hard part is getting that JVM installed.
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
Huh ? At this time and age, no mention of automake/autoconf at all or did the review just skip that part ?
Who in their right mind still uses handwritten makefiles ?
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.slashdot.org Errors found while checking this document as HTML5!
I always thought it was more like the "Infinite number of monkeys..." thing. I mean... with all the "eyes" that are supposedly on OSS code kinda being like an "Infinite number..." and, well, the average OSS programmer probably kinda smells and acts like a "monkey"... ;)
Writing Linux applications is not a simple endeavor
Um. What?
I've found writing Linux applications rather simple to be honest. Pick any well-known distribution and you instantly have a solid development environment within which to work. Everything you need is "right there". You even get a great wealth of knowledge to base your development on. Want to code a network driver? Just take a look at the source code! Want to go high-level? There are a plethora of tools and libraries all with source, as well as a veritable treasure trove of documentation. On top of this you have IRC and USENET!
Compare this to writing a device driver in Microsoft Windows. You start from scratch. Everything is closed. Try to find someone knowledgeable, and you're met with eother hostility or blank looks. Anything you want to do means shelling out a lot of hard earned cash - and thats just to get a development environment!
Here's a program that uses recursion, threads, and condition variables to print "Hello, world!"
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
struct thread_info
{
pthread_t id;
pthread_mutex_t lock;
pthread_cond_t cond;
int ch;
struct thread_info *next_thread;
};
void *do_thread(void *arg)
{
struct thread_info *inf = (struct thread_info *)arg;
pthread_cond_wait(&inf->cond, &inf->lock);
printf("%c", inf->ch);
if(inf->next_thread)
{
pthread_mutex_lock(&inf->next_thread->lock);
pthread_cond_broadcast(&inf->next_thread->cond);
pthread_mutex_unlock(&inf->next_thread->lock);
pthread_join(inf->next_thread->id, NULL);
}
return NULL;
}
struct thread_info *build_chain(const char *str)
{
struct thread_info *inf;
if(!*str)
{
return NULL;
}
inf = calloc(1, sizeof(*inf));
pthread_mutex_init(&inf->lock, NULL);
pthread_cond_init(&inf->cond, NULL);
pthread_mutex_lock(&inf->lock);
inf->ch = *str;
pthread_create(&inf->id, NULL, do_thread, inf);
inf->next_thread = build_chain(str + 1);
return inf;
}
int main()
{
const char *str = "Hello, world!\n";
struct thread_info *chain;
chain = build_chain(str);
pthread_cond_broadcast(&chain->cond);
pthread_join(chain->id, NULL);
return 0;
}
I see the greater problem in the fast pace of Open Source development. Lots of books especially on new and developing topics are already outdated once they appear on the shelves.
I agree to the first statement; this is probably why documentation *always* sucks, both the electronic and the print versions.
But there are a few books worth reading, mainly those about standards. X11 protocol (and Xlib), POSIX or network books with 'cleaned up' versions of important RFCs provide knowledge beyond the next major version of $foo.
I guess that's why I really like standards.
Well, it's not Hello World, but here is the factorial function presented as The Evolution of a Haskell Programmer
But I just want to give a different perspective.
How useful would this book be to the average developer,
I mean really, really ? I have a book on my shelf called
Linux Programming By Example (2000)
Its a good 5 years older than this book but the book reviewed doesnt seem to improve much on it. The same topics (more or less ) are covered from systems programming , process management and using Berkley DB. I havent really read the book , opened it once or twice to find out about the Berkley API ( information I could easily have found on the net ) and thats about it. All I did was refer to it, I found it a bit to boring to read.
Now why is it that? IMHO I think that these books try out to do what the internet does already well, that is provide a good solid reference for programming tasks.
Almost everything I have learnt about Linux development has been from internet resources and not from books that I have bought or read. I think there should be more books
out there that show you how to stitch things together,
or use the different ( commonly used ) technology together to solve particular problems.Not algorithmic problems but just general application architecture from
Linux Dev perspective.. How do I build a robust application,scalable application using Open Source tools?
And most of the problems I have encountered in Linux Dev is in GUI dev. Very few books , intelligently touch on WxWindows, QT dev or even how to use GTK2 in the context of application development.
Very few books show us how to integrate our applications into a Linux Desktop environment. A lot of OSS apps
seem to give the feeling that the interfaces took less
than week to do after skimming thru the GTK or QT tutorials.
I digress, back to my main point. We need to know how to
stitch things together with what we have.
Qt, KDE and PyQt/PyKDE are far better GUI development solutions than anything Microsoft has ever put out, .NET included.
You're either a troll or a dimwit.
Sigh. This is such a friendly place.
It's the open-source MPEG2-video (i.e. DVD) creation package.
Um. That's nice and all, but it sounds from skimming the marketing hoo-hah that it's drastically inferior to products like Compressor and Cleaner. No real-time preview, no support for other codecs, no queueing or batch-processing facilities, no user-friendly interface.
It's a new temporal noise-reduction tool for digital video, that does such a good job of inferring clear images from several noisy examples of them, that it can make a videotape look like it came from a LaserDisc. No kidding.
I'm sure you're not kidding, because Sonic has had that tool for at least seven years now. I first saw it in 1998. And they had a real nice application wrapped around it, too, which is more than I can say for "mjpegtools."
It always kinda strikes me as odd when someone tries to cover Linux application programming in one book. I mean, look at the ridiculous number of choices one has to make before even writing the first line of code.
1) KDE(QT), Gnome(GTK), or others
2) What distros will this work on... "this won't work on anything short of Red Hat 9 unless you upgrade all these libs"
3) Are there any nice pre-written components to let me get this on the shelf sooner... well yes but this ones written in QT and I've decided to do my project in GTK.
4) Lastly... "I need help with this error message I'm getting". Community response: sign up to this major domo newsletter and maybe someone will answer (if were not already tired of answering your dumb question for the last guy that asked).
I hate to be too sarcastic... but it really sucks to be a Linux developer don't you think. There are lots more people doing windows development and most of them using alot less different tools to get the job done. Chances are I can find the exact windows error message I'm trying to debug on a website somewhere. People who truly love Linux will point to it's diversity as it's strength. That diversity is a double edged sword however. Yes... you have the freedom to choose from X number of programming environments- but ultimately Linux is losing out the developers can't all get on the same bout. Thank goodness everyone at my company is using the same tools/language/operating system. I guess I'll end my rant now. Moderators please: I do check my replies so please write an intelligent response rather than killing my karma because you don't agree with me.
Seeing as how we're discussing Linux applications and all...how about some URLs for Compressor, Cleaner, or Sonic?
"Once we've identified and embraced our sickness, we'll have strength...and that's when we get dangerous." - John Waters
(I thought about doing something totally ridiculous, like having the-msg be a red-black tree indexed by the Nth prime number, but then I realized that would be totally ridiculous)
Hurry up and jump on the individualist bandwagon!
Hurry up and jump on the individualist bandwagon!
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
Hello. Welcome to slashdot.
Would you like a clue?
Compressor, Cleaner... say I wonder if I can download a free copy of those to run on my Solaris box.
No? Well, it's back to handrolling an implementation from the ITU MPEG-2 reference documents.
I guess mjpegtools is USELESS then...
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
Arigato, dude; arigato gosaimasu.
Those who sacrifice security to condemn liberty deserve to repeat history or something. - Benjamin Santayana
I have had this book for three years, and it's excellent in both writing quality and examples. It's strictly console oriented, go somewhere else for GUI programming, but it's by far the best, most clear, and comprehensive source of info for creating programs that need to do Linux system calls.
If you're a programmer.
Best Slashdot Co
I find man pages very useful in most cases. But what on earth is the point of info pages? Is there anything about them that cannot be done in HTML 2.0 and lynx?
Beta is broken and the link to classic doesn't work. Stop wasting our time or there won't be anybody left here.
So where's your implementation, cocksucker?
although looking at man 3 readline... I don't think you'd need a book to cover that. :-)
;)
Sorry, I didn't read the book. But I mean there are lots of applications which are not GUI oriented... well so most of them are computing environments or expert systems but people pay a lot of money for them!
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
Is it sophisticated or poorly designed? Has anyone ever seen an X Application that looked and felt as nice as a native Windows (or Mac OS X) application? Has anyone ever gotten stuff like drag/drop between applications or ICCCM to work correctly? I'd say it's far from sophisticated--it's clunky, ill conceived, and hard to apply effectively.
Best Buy can have you arrested