Appendix B. UNIX Error Messages

Errors generated by the failure of a system call or library function, can be displayed using the perror or strerror library function calls (see “Managing FailuresSection 1.5, “Managing System Call Failures”). For example, the error messages returned by strerror on a Linux system can be displayed in their entirety using Program B.1.

Example B.1. Displaying strerror messages.

File : errors.cxx
  |     #include <iostream>
  |     #include <cstring>
  |     #include <errno.h>
  |     extern int sys_nerr;
  +     using namespace std;
  |     int
  |     main( ){
  |       for (int err=0; err < sys_nerr; ++err )
  |         cout << err << '\t' << strerror(err) << endl;
 10       return 0;
  |     }

As the output of the program will fill more than one screen, it may be helpful to redirect ...

Get Interprocess Communications in Linux®: The Nooks & Crannies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.