You can use lsof (available for just about any Unix variant, but often not part of the default installation) to list all the files a process is using. “Using” includes open file descriptors as well as closely related concepts such as which executable the process is running. The executable has txt in the FD column, for obscure historical reasons.
$ lsof -p1234 | grep txt
a.out 1234 user15964 txt REG 253,0 34567 /path/to/a.out
(made-up output)
On Solaris and Linux, there's a more direct way: the proc filesystem provides information about each process, including which executable it's running. (On Linux at least, that's where lsof gets its information.)
$ ls -l /proc/1234/exe
lrwxrwxrwx 1 root root 0 Feb 30 34:56 /proc/1234/exe -> /path/to/a.out
If you're looking for a process running a given executable, run fuser.
$ fuser /path/to/a.out
/path/to/a.out: 1234e 1239e
/proc/$PID/exeisn't a standard symlink. – Wildcard Apr 08 '16 at 01:57ls -l /procshow anything? – Wildcard Apr 08 '16 at 01:59psshow the contents of /prod/$PID/exe right? I was looking for such option but couldnt find it onps, or I missed something? – Aquarius Power Mar 02 '17 at 23:27