$ strace ls
Traces all the system calls invoked by the process “ls”
Let’s say we are in directory dir and we execute ls
$ ls
file1 file2
And now, let’s see what the command actually does:
$ strace ls
open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|0x80000) = 3
getdents(3, /* 4 entries */, 4096) = 112
write(1, "file1 file2\n", 13file1 file2
) = 13
It opens the current directory, reads the number of entries (4, this is: our two files, plus “.” plus “..”) and writes the result using write
You should keep in mind that strace traces system calls and not libc functions (that are actually wrappers for system calls). So if you want to find information about some of the syscalls reported by strace you should look up in man section 2
Add your comment below, or trackback from your own site.
Subscribe to these comments.
Be nice. Keep it clean. Stay on topic. No spam.
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>