Re: finding the full path of the program which ran.



On 2006-12-21, Joe Pfeiffer <pfeiffer@xxxxxxxxxxx> wrote:
John Reiser <jreiser@xxxxxxxxxxxx> writes:

I m building a library which requires the full path of the program to
which it is linked. How could I do it?

This is impossible if you require an answer that is always correct
regardless of circumstances.

The presence of hard links and symbolic links allows for many different
names for the "same" program. So "_the_ full path" might be ambiguous.

(snipped lots of good information)

Never mind that the full path at link time isn't likely to be the same
as the full path at run time.

Well, he did say "is linked" rather than "was linked", so I
assumed he wanted the current path of the current executable in
who's context the library is executing.

There isn't really a good, general way to find out. Most
people who want to know are asking for the wrong reasons
anyway. Usually when people ask "how do I find the location of
the program's exectuable" it's becuase they're Windows
programmers who think configuration files are stored in the
same directory as executables.

Under Unix that's most definitely _not_ where configuration
files go, so there shouldn't be any real need to know.

--
Grant Edwards grante Yow! Jesuit priests are
at DATING CAREER DIPLOMATS!!
visi.com
.



Relevant Pages

  • Re: finding the full path of the program which ran.
    ... | who's context the library is executing. ... | programmers who think configuration files are stored in the ... I see more users doing this to find resource files, ... than it's original file basename, ...
    (comp.os.linux.development.system)
  • Re: Re: Login problem
    ... My system is opening without executing those files and I am looking for ... It is like that there is a nologin specification somewhere in ... configuration files. ... I created another linux user and tried with it but nothing is changed. ...
    (Debian-User)
  • Re: Strange if statement
    ... >Is this if statement purely looking for the prescence of the variable of ... >$result before executing? ... Presence, maybe, or perhaps a "null" error result from some API. ... Prev by Date: ...
    (comp.lang.php)