When an application needs to access one of the services provided by the kernel, the application typically invokes a system call. When a system call returns, the system call will typically provide a return value to indicate success or failure, and in the case of a failure, the global errno variable will be set to indicate the specific error that occurred. To see what errors are occurring on a system or within a specific process, the DTraceToolkit’s errinfo script can be used:
$ errinfo -n _app
EXEC SYSCALL ERR DESC
_app stat 2 No such file or directory
_app lseek 29 Illegal seek
_app pause 4 interrupted system call
This will print the system calls that returned with an error condition, the value of the errno, and the error number description from errno.h. This is a super useful script, and can make tracking down errors super easy.