Full path to running program

rationull

Registered
Is there any way (either a OSX utility or a BSD command) to find out the full path to the program running in a given process? Using ps -A I can get the full path to most, but not all running programs. I want a way to associate any pid with a specific executable file and I can't seem to find one.
 
You can use the "which" command from the command line. Just run ps -A and copy the process name you want to find. Then paste it after which.

$which <process name>

That should print the path.
 
In my understanding, that will only print the path to the command with that name that is first found when searching the $PATH, not necessarily the actual executable that's running (if, for example, there are two programs with the same name in different directories on the system).

I came up with a workaround though.. Using lsof to list the open files associated with a pid seems to always show the full path to the program among its output, as the process will have its program file opened.
 
Back
Top