Viewing system call errors with DTrace


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.

This article was posted by Matty on 2006-03-13 09:56:00 -0400 -0400