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

You are right, apologizes for being very unclear on my wordings here.

I totally understand that there is no way to literally retrieve "the
path of the executable
currently running". That doesn't make sense, as you stated and
demonstrated. The file
could have been removed, replaced, the partition unmounted, or
whatever other million
of reasons. Maintaining a relationship between a path and a running
process on unix
doesn't make sense.

Allow me to rephrase it with a clearer wording then:
We need the path that was provided to execve(), and thus contained -
at that time - the
ELF that was loaded".

We don't need to - and can't - make any sort of guarantee on this
path, it is just informational, and
can be used by ld.so to perform $ORIGIN substitution.

On Sat, Dec 12, 2015 at 2:19 PM, Raul Miller <rauldmil...@gmail.com> wrote:
> 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



--
Aurélien Vallée
Phone +33 9 77 19 85 61

Reply via email to