The most ghetto of possible methods on Linux is to resort to mucking about in proc:
ls -sla /proc/20963/exe 0 lrwxrwxrwx 1 foo bar 0 2011-05-25 02:29 exe -> /bin/zsh4
It isn't stable to look at argv[0] (/proc/$PID/cmdline) and of course this isn't portable at all.
The most ghetto of possible methods on Linux is to resort to mucking about in proc:
ls -sla /proc/20963/exe
0 lrwxrwxrwx 1 foo bar 0 2011-05-25 02:29 exe -> /bin/zsh4
It isn't stable to look at argv[0] (/proc/ $PID/cmdline) and of course this isn't portable at all.