Re: finding datadir from executable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 11 Sep 2004, Ralph Corderoy wrote:

You give it argv[0], BINDIR, and OTHERDIR; it computes the relative
path between bindir and otherdir, finds your application in $PATH or
similar, and works out the likely location of otherdir.

Does argv[0] always contain a path on all Unixes? IIRC, some old ones put just `ls' there despite execve(2) being given "/bin/ls".

In my experience argv[0] does not always contain a full path. It generally contains whatever was used to execute the program. For example it could contain "../foo/bar". Usually if the program was executed via the executable search path, it contains a full path. If your application is compiled under Windows (e.g. MinGW), you can expect more interesting issues since the path may include drive letters or SMB \\ prefixes. Windows and Solaris provide function calls which return the path to the executable directly without use of argv[0].


The burden is on the programmer to figure things out within their application and therefore this issue is not an Autoconf-related topic.

Bob
======================================
Bob Friesenhahn
bfriesen@xxxxxxxxxxxxxxxxxxx
http://www.simplesystems.org/users/bfriesen


_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux