2

I am already familiar and successfully dumped the files opened by a process using strace. With that being said, strace performance is causing degradation for my software and I would like to implement a wrapper using c++ for my software, in a way that ptrace will collect and dump files opened by the software.

I have found guides on how to attach, and modify registries - but that doesn't really help with anything.

Appreciate the help.

Nisan Bahar
  • 73
  • 1
  • 1
  • 8

1 Answers1

0

On linux, you can access the list of all open files in /proc/<pid>/fd. This directory contains just a bunch of symlinks for each open file; using standard directory iteration, you can create a list of open files very easily, e.g. on the terminal:

ls -l /proc/$(pidof bash)/fd/

For creating a C/C++ wrapper, you can e.g. use the techniques described in this related question: How to list files in a directory in a C program?

Philipp Ludwig
  • 3,758
  • 3
  • 30
  • 48