On Sat, Dec 12, 2015 at 6:34 AM, Aurélien Vallée
<vallee.aurel...@gmail.com> wrote:
> It seems like most other unixes out there do have a way to retrieve the
full
> path of a running program, mainly through /proc (be it /proc/pid/exe on
> Linux, or /proc/pid/path/a.out on Solaris (TBV).

An issue, though, is that this path does not have to refer to a file
which has anything to do with what the process is doing.

Here's an illustration:

#!/bin/sh
set -e
mkdir -p $HOME/bin
rm -f $HOME/bin/example[12]
cp /bin/sleep $HOME/bin/example1
ln $HOME/bin/example1 $HOME/bin/example2
$HOME/bin/example2 100 &
rm -f $HOME/bin/example2
cp /usr/bin/false $HOME/bin/example2
echo "what is the full path for process $!?"

Seriously, though: understanding the unix process/file model is
critically important if you are going to make any useful contributions
to the implementation. But I am not sure where to refer you to get the
basic idea. (I got mine from reading source code comments for a very
early version of unix.)

All the docs I find through searching go into a lot of detail about
steps and procedures, but what I think you really need is something
cruder. I don't know where to point you for that, though - perhaps
such things have been lost to the mists of history?

Good luck,

--
Raul

Reply via email to