in reply to (OT) Logging open calls from a C program

Not exactly a Perl question... (please at least mark as OT).   Anyway, use one of strace, truss, tusc, StraceNT, ... depending on platform.

Update: This node has gotten a higher reputation than I expected :)   So, as a kind of 'thank you!', and as there apparently exists some interest in the issue, I decided to add some more value (well, hopefully so). Sure, Google knows it all, too, but for easy quick reference...

BTW, several 'classical' Unices do feature an unrelated strace command... so, just because there is a program called strace, don't be fooled into believing that this is what you're looking for... (that's 'STREAMS trace', rather than syscall tracing).

Corrections, additions welcome.

Replies are listed 'Best First'.
Re^2: (OT) Logging open calls from a C program
by archfool (Monk) on Jul 28, 2007 at 22:00 UTC
    lsof would work, too. (LiSt Open Files). Comes default with linux, can be compiled for other unix-es.
      I don't think lsof can replace a call trace in this case. The requirement is

      I need to see what files a program is opening,...

      which I read as "List all files the program opens during its lifetime". With lsof you get a snapshot of the files that are open at the moment. You'll miss files that were open but have been closed again, as well as those the program hasn't opened yet.

      Anno

      Very few things come as defaults with Linux - it will depend upon your distribution ..

      Steve
      --
Re^2: (OT) Logging open calls from a C program (system call tracing tools)
by superfrink (Curate) on Jul 30, 2007 at 07:13 UTC
    ktrace is also used on OpenBSD. Check for it on other BSD platforms if you happen to be use one.

    Solaris 10 has a new tool called dtrace but as far as I know truss still works.

    Update: You might also be able to use a debugger like gdb but I would use one of the tracing tools.