Linux strace - . :.
$ strace -o/tmp/blah -f -eopen,read bash -c "cat ciao.txt"
( , , - -f), /tmp/blah (120 ), , , .
, , , ; , Python, :
import re
linere = re.compile(r'^(\d+)\s+(\w+)\(([^)]+)\)\s+\=\s*(.*)$')
def main():
openfiles = dict()
filesread = set()
with open('/tmp/blah') as f:
for line in f:
mo = linere.match(line)
if mo is None:
print "Unmatched line %r" % line
pid, command, args, results = mo.groups()
if command == 'open':
fn = args.split(',', 1)[0].strip('"')
fd = results.split(' ', 1)[0]
openfiles[fd] = fn
elif command == 'read':
if results != '0':
fd = args.split(',', 1)[0]
filesread.add(openfiles[fd])
else:
print "Unknown command %r" % command
print sorted(filesread)
( , dup c), , , . :
['/lib/libc.so.6', '/lib/libdl.so.2', '/lib/libncurses.so.5',
'/proc/meminfo', '/proc/sys/kernel/ngroups_max',
'/usr/share/locale/locale.alias', 'ciao.txt']
, "" , , " "... , . , , .
strace , , Windows, , StraceNT - 100% , , , & c , , Python ( strace ).
, Unix, , , root () - . Mac OS X sudo dtrace dtruss; strace Mac root.