find pid of process run in specific location

Hello,

I have a process a.out that runs from /a and /b
How can I get the pid of the one running from /a
ps -C /a/a.out
does not work

Thanks!

Hi,

Have a look at the manpage for fuser command.
lsof is another tool often used to identify processes.

Hi Cero,
Thank you very much; I did not know those commands.

a.out is actually a fastcgi program and I need to kill every running processes of that program. Would
fuser -k /a/a.out
do the trick?
I am a bit confused because the man page of fuser reads:
-k Kill processes accessing the file. Unless changed with -signal, SIGKILL is sent. An fuser process never kills itself, but may kill other fuser processes. The effective user ID of the process executing fuser is set to its real user ID before attempting to kill.

Hi JCR,
fuser -k should do the trick. The manpage tells you that the privileges of your user are used when trying to kill the process.
For fuser the setuid-bit is set (at least on AIX) :

ls -la /usr/sbin/fuser
-r-sr-xr-x   1 root     system        19084 Mar 16 2007  /usr/sbin/fuser

This means that the process running the fuser command operates with root-privileges (= it's effective user ID is root), which would allow you to kill any process with this command. To prevent this the process switches back to the user you logged on and operates with those privileges before attempting to kill another process.

Did this clear things up for you?

man pkill