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
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