Re: argv[0]?
From: Casper H.S. Dik (Casper.Dik_at_Sun.COM)
Date: 11/01/04
- Next message: Richard Herring: "Re: Welcome back Paul Lutus"
- Previous message: Arthur J. O'Dwyer: "Re: Not STD C is "not C" ? ----WAS: Re: C to Java Byte Code"
- In reply to: ms419_at_freezone.co.uk: "argv[0]?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 01 Nov 2004 09:40:25 GMT
ms419@freezone.co.uk writes:
>What should the first argument - argv[0] - be when executing an
>executable?
>>From the execv manpage:
> The first argument, by convention, should point to the file name
>associated with the file being executed.
"By convention .... should ...."
Roughly translates to "may or may not"
>Does this mean the path which was executed or just the last component?
>or does it matter? Is more information available elsewhere?
It could be anything what the shell or whichever program puts there.
- by convention, login(1) invokes the shell with argv[0]
equal to -sh (or -ksh or whatever)
- by convention, shells put the command as typed in argv[0]
(after alias/variable expansion); so they use "cat" and not
"/bin/cat" and you need to search $PATH
- by convention, only programs invoked using the full pathname will
have the full pathname there.
Casper
-- Expressed in this posting are my opinions. They are in no way related to opinions held by my employer, Sun Microsystems. Statements on Sun products included here are not gospel and may be fiction rather than truth.
- Next message: Richard Herring: "Re: Welcome back Paul Lutus"
- Previous message: Arthur J. O'Dwyer: "Re: Not STD C is "not C" ? ----WAS: Re: C to Java Byte Code"
- In reply to: ms419_at_freezone.co.uk: "argv[0]?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|