strace用来跟踪一个进程的系统调用或信号产生的情况,使用很简单。
[root@localhost ~]# strace -eopen `which free`
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib/libproc-3.2.3.so", O_RDONLY) = 3
open("/lib/tls/libc.so.6", O_RDONLY) = 3
open("/etc/mtab", O_RDONLY) = 3
open("/proc/stat", O_RDONLY) = 3
open("/proc/meminfo", O_RDONLY) = 3
total used free shared buffers cached
Mem: 483176 475936 7240 0 387888 15264
-/+ buffers/cache: 72784 410392
Swap: 6152900 208 6152692
一下就可以看出系统怎么调用的了。