Failed System Calls (cont)
Action in response to failed system call is often e.g.
fprintf(stderr, "Can't do %s", Something);
exit(1);
|
Can give more precise feedback via library functions, e.g.
-
void perror(char * Message)
- writes to
stderr
- writes message and standard message corresponding to
errno
- Also see the
strerror function
Could then do exit(errno); to send precise error to shell.
To show the exit code after the program has run type
echo $? in your terminal.
|