Saturday, August 11, 2012

Linux: find out what the system error code means

If your system has the perror installed, simply type
$ perror <error_no>

for example
$ perror 8
OS error code  16:  Device or resource busy

If perror is not installed, it is not difficult to write your own version in 5 minutes.

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
   if (argc < 2)
      printf("Usage: %s <error_no>\n", argv[0]);
      return 0;

   int errNo = atoi(argv[1]);

   printf("Error %d: %s\n", errNo, strerror(errNo));

   return 0;

No comments:

Get This <