System call exit status Every system call has a return value - check them! Usually -1 indicates error On error, the variable 'errno' is set, for example EBADF -- file descriptor not opened for writing EACCES -- access (to file) denied EPERM -- permission (for action) denied EROFS -- read only file system Error message for errno can be printed using perror() perror("Unable to open file foo: "); /* may yield "Unable to open file foo: no such file or directory" */ Or via sys_errlist[] fprintf(stderr, "Error: %s\n", sys_errlist[errno]); Or via strerror() fprintf(stderr, "Error: %s\n", strerror(errno)); errno is cleared after a sucessful system call