tech-misc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

any interest in tracking of file descriptors by ktrace/kdump?



Hi,
I have a prototype of FD tracker that prints a list of open file
descriptors of a program being exec'ed. It's handy in situations
where you don't know which descriptors have closeexec flag set.
If there is an interest, I can polish my changes and submit a patch.
Thanks,
Alex

$ env -i PATH=$PATH ktrace -tA ls
$ kdump 
 10596      1 ktrace   EMUL  "netbsd"
 10596      1 ktrace   RET   ktrace 0
 10596      1 ktrace   CALL  execve(0xbfbfe9f8,0xbfbfeed0,0xbfbfeed8)
 10596      1 ktrace   NAMI  "/home/alnsn/bin/ls"
 10596      1 ktrace   RET   execve -1 errno 2 No such file or directory
 10596      1 ktrace   CALL  execve(0xbfbfe9f8,0xbfbfeed0,0xbfbfeed8)
 10596      1 ktrace   NAMI  "/bin/ls"
 10596      1 ktrace   NAMI  "/libexec/ld.elf_so"
 10596      1 ktrace   ARG   "ls"
 10596      1 ktrace   ENV   
"PATH=/home/alnsn/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/\
        pkg/bin:/usr/pkg/sbin"
 10596      1 ls       FD    0
 10596      1 ls       FD    1
 10596      1 ls       FD    2
 10596      1 ls       FD    6
...

$ fstat -p $$
USER     CMD          PID   FD MOUNT       INUM MODE         SZ|DV R/W
alnsn    ksh        19741   wd /home    7790072 drwxr-xr-x    1024 r 
alnsn    ksh        19741    0 /dev/pts      11 crw--w----   ttyp4 rw
alnsn    ksh        19741    1 /dev/pts      11 crw--w----   ttyp4 rw
alnsn    ksh        19741    2 /dev/pts      11 crw--w----   ttyp4 rw
alnsn    ksh        19741    6 -         -        none    -
alnsn    ksh        19741   10 /         130960 crw-rw-rw-   1409,305448 rw



Home | Main Index | Thread Index | Old Index