JMU
UNIX System Calls
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


Background Definitions (The Narrow View)
New Definitions
Error Handling
Error Handling (cont.)
A Handy Library Function: perror() perror
void perror(const char *prefix);
Purpose:
Write a message describing the last error encountered to standard error
Details:
prefix The prefix to the message
#include <stdio.h> stdio.h
Error Handling (cont.)

A Rudimentary Example

  fd = open(path, flags, mode);

  if (fd == -1)
    {
      perror("Error");
      exit(EXIT_FAILURE);
    }
  
Error Handling: (cont.)
Another Handy Library Function: strerror() strerror
char *strerror(int n);
Purpose:
Return a string describing an error
Details:
n The error number (e.g., from errno)
#include <string.h> string.h
Some Details of System Calls
Some Details of System Calls (cont.)
System Data Types
Learning About System Calls
Learning About System Calls (cont.)
Library Functions