Topic: Open Source

Beginning Linux Programming, 2nd Edition (0764543733) cover image

Beginning Linux Programming, 2nd Edition

Richard Stones, Neil Matthew, Alan Cox (Foreword by)
ISBN: 978-0-7645-4373-9
1008 pages
January 2000
View Most Recent Edition of This Title
This title is out-of-print and not currently available for purchase from this site.

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.

ChapterPageDetailsDatePrint Run
0 'Gnome clock' code - missing brackets around the else statement

Page 665, point no. 12, 'else' section of code - braces missing.

  gnome_canvas_item_set (hand, "points", points, NULL);
  gnome_canvas_item_set (second_hand, "points", second_hand_points, NULL);
14-Nov-02 1
2 34 file mstakenly named as 'first' in code bundle

The script is provided in the code bundle available for download, with the name 'first'. It should be renamed to ''.

16-Jan-03 1
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.

16-Jan-03 1
128 ISO/ANSI C states that main() must return int

Line 16:

It is stated that:
"Although ISO/ANSI C leaves open the return type of main (it may be void or int)....

In fact, ISO/ANSI C states that main() must return int.

Thanks to Jordan Katz for spotting this.

19-Jan-00 1
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.

#include <stdio.h>
#include <time.h>
int main ()
struct tm *tm_ptr;
time_t the_time;

(void) time(&the_time);
tm_ptr = gmtime(&the_time);
printf("Raw time is %ld \n", the_time);
printf("gmtime gives :\n");

printf("date: %04d/%02d/%02d\n", tm_ptr->tm_year+1900, tm_ptr->tm_mon+1,tm_ptr->tm_mday);
printf("time: %02d/%02d/%02d\n", tm_ptr->tm_hour, tm_ptr->tm_min, tm_ptr->tm_sec);
27-Sep-02 1
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


#include <time.h>
#include <stdio.h>

int main()
    struct tm *tm_ptr, timestruct;
    time_t the_time;
    char buf[256];
    char *result;

    (void) time(&the_time);
    tm_ptr = localtime(&the_time);
    strftime(buf, 256, "%A %d %B, %I:%S %p", tm_ptr);

    printf("strftime gives: %s\n", buf);

    strcpy(buf,"Mon 26 July 1999, 17:53 will do fine");

    printf("calling strptime with: %s\n", buf);
    tm_ptr = &timestruct;

    result = strptime(buf,"%a %d %b %Y, %R",tm_ptr);
    printf("strptime consumed up to: %s\n", result);

    printf("strptime gives:\n");
    printf("date: %02d/%02d/%02d\n",
    tm_ptr->tm_year, tm_ptr->tm_mon+1,tm_ptr->tm_mday);
    printf("time: %02d:%02d\n",tm_ptr->tm_hour, tm_ptr->tm_min);    
04-Oct-02 1
10 354 char* const

In the exec function to start the ps program, the line:
const char *ps_argv[]="{"ps", "-ax", 0}";
needs to be replaced by:
char * const ps_argv[]="{"ps", "-ax", 0}";

23-Jan-03 1
366 Misplaced word

Line 5:
"Ctrl-C, which." should be "Ctrl-C."

14-Apr-00 1
367 missing piece of code
Line 25:
The code in step number 2 should start with the following (before pid_t pid;)

int main()
14-Apr-00 1
380 Spelling Errors

Line 13:
"where" should be "were"

Line 22:
"it's" should be "its"

22-Mar-00 1
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"

24-Jul-02 1