Created by Alex Juarez / @mralexjuarez
strace can interrupt a process intercepting system calls and their return codes.
A system call is a function provided by the kernel. They are the basic interface between an application and the Linux kernel.
strace can trace a process that is run with strace
We can be a bit more verbose and get all the details
strace can trace a process via an existing pid
A traced process which tries to block SIGTRAP will be sent a SIGSTOP in an attempt to force continuation of tracing.
Save the output to a file
strace can trace child processs
The output is standardized and can go to stderr or to a file.
Summary of the system calls
If the processes exited normally
If a process was killed by a signal
A system call is a function provided by the kernel. They are the basic interface between an application and the Linux kernel.
There are about 441 system calls.
Some are synonyms for others.
(*Based of a quick search of man pages)Each system call has it's own man page. Keep in mind that some programs and system calls have the same name.
# man read
Just using man read, returns the page on bash-builtins
The second section of the man page is what we need.
# man 2 read
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\34\2\0\0\0\0\0"..., 832) = 832
int open(const char *pathname, int flags, mode_t mode);
Given a pathname for a file, open() returns a file descriptor
ssize_t read(int fd, void *buf, size_t count);
On success, the number of bytes read is returned
int fstat(int fd, struct stat *buf);
These functions return information about a file.
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
returns a pointer to the mapped area.
We can trace families of system calls
We get more info by using -v
.htaccess and file access
Apache's document root is stored on an NFS mount and has been working for some time.
All of a sudden performance takes a hit and pages are loading much slower than before.
This hCard created with the hCard creator.
Alex Juarez is a Principal Engineer at Rackspace, touting 8 years with the company. Alex enjoys all things Linux, especially training and mentoring others, and is incredibly qualified to do so as an RHCA/RHCI. When Alex isn't helping others he's crafting killer cocktails and finding the best spots to grub in San Antonio.
Thanks @jilljubs