I need to find the open files of the current process in C Linux. So far all I could figure out was current -> task_struct… then there aren’t a log of resources…eventually I’m supposed to get to open_fds? Also, is the endpoint a bitmap file? How would you get the open files from the bitmap structure or some other weird structure?
I need to find the open files of the current process in C Linux.
Share
on the command line
lsofin C, something like this:
Here is the commented code of a program that prints on screen a list of its own open files:
This code is from: http://mydebian.blogdns.org/?p=229 , which is cached here: http://tinyurl.com/6qlv2nj
See:
How to use lsof(List Opened Files) in a C/C++ application?
http://www.linuxquestions.org/questions/linux-security-4/c-library-for-lsof-183332/
you could also use the
lsofcommand via apopencall.