Which process has created a file ?

Hi All,

We have a multi-threaded application.

During the course of action, each process creates some files. Is there any way to know which process has created a particular file ?

Ex:
Suppose we have 3 process running A, B and C in the application and some files FILE1 FILE2 FILE3 and FILE4 are generated when the application is ran, is there any way to map the peocess(es) [A, B, C] to the files [FILE1 FILE2 FILE3 FILE4] created by them ?

Any help would be appreciable.

Thanks & Regards,
14341

Which? Is it multiple threaded, or multi-processing? Or perhaps both?

This only works for processes, not threads, but you could run each instance under a different user id. The resulting files would belong to the corresponding user.

---------- Post updated at 09:40 AM ---------- Previous update was at 09:37 AM ----------

Otherwise, I would have the threads use better names for the files... Instead of file1 file2 file3 file4, file-<threadid1>, file-<threadid2>, file-<threadid3>, file-<threadid4>. The name itself will tell you what you need to know.

On what system are you running this application?

Hi Guys,

Thank you for your suggestions.

Corona688,

Yes the application is both multi-processed and multi-threaded one.

The application comprises of both C++ code, Java code and some 3rd party integration as well.

No one has (I think no one will ever have) a control on the code flow of the overall application since it is very huge (only source code is around 600 MB without compilation) and has many branches.

This app is an acquired product and we are short in terms of the documentation

I was just trying to figure out if there is any way (without modifying the entire source-code) to find out the correlation between the files-created Vs process.

Like from inode structure or something similar.

Bartus11,

The application is being run on both SOLARIS and RHEL.

Please pour in if you have any suggestion(s).

Thanks & Regards,
14341

On Solaris (assuming you are running version 10 or higher) you can use DTraceToolkit (DTrace Tools). Particularly the "rwsnoop" tool with "-n app_name" option.