How to get PID of a process causing an event of a file or folder?

131 Views Asked by At

While using inotif function in C language to watch a directory, is it possible to get the pid of the process causing an event on the watched folder? I have tried searching but did not get any break through. Or any suggestion. like is there a way using some external function of any other module to get the pid whenever inotif generates an alert. A different module which will compare the event.

Further explaining, inotif will watch the directory for any Create/Modify events. During any events, at the same time we want to identify the process maybe get the PID.

1

There are 1 best solutions below

0
Dillip Murali On

You might not have to install any separate kernel modules for that

You might be aware of the ps command in linux which lists all processes there along with ps you can grep with your filename

ps | grep filename

Try using the above command in terminal