How does a program get its path name?
Andrew Scherpbier
turtle at sdsu.UUCP
Mon Feb 22 02:38:57 AEST 1988
In article <11923 at brl-adm.ARPA> Leisner.Henr at xerox.com (marty) writes:
>How does an exec program get the pathname it was execed from if it wants to find
>out this information?
>
>(I'm specifically asking how cc knows to looks at ../lib for the compiler
>passes).
>
>marty
When a program executes, the full path to the executable file is kept in
the zero-th argument. If you have a declaration of main which looks like this:
main(argc,argv)
int argc;
char *argv[];
then argv[0] is a pointer to the full path.
Is this what you were looking for?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~T~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"I sometimes get the feeling that | Andrew Scherpbier
things cannot possibly get worse...| Computer Science Department
and sure enough, they do." | San Diego State University
-Don Perkins Jr. | ihnp4!jack!sdsu!turtle
More information about the Comp.unix.questions
mailing list