Path: utzoo!mnetor!uunet!husc6!uwvax!oddjob!hao!ames!ucsd!sdcsvax!ucsdhub!sdsu!turtle From: turtle@sdsu.UUCP (Andrew Scherpbier) Newsgroups: comp.unix.questions Subject: Re: How does a program get its path name? Message-ID: <2933@sdsu.UUCP> Date: 21 Feb 88 16:38:57 GMT References: <11923@brl-adm.ARPA> Reply-To: turtle@sdsu.UCSD.EDU (Andrew Scherpbier) Organization: San Diego State University, Math/Sciences Dept. Lines: 23 In article <11923@brl-adm.ARPA> Leisner.Henr@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