Re: argv[0]?

From: Casper H.S. Dik (Casper.Dik_at_Sun.COM)
Date: 11/01/04


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.


Relevant Pages

  • Re: ZFS theoretical capacity
    ... >> This does not really matter as it would be sufficient to support ... Expressed in this posting are my opinions. ... to opinions held by my employer, Sun Microsystems. ...
    (comp.unix.solaris)
  • Re: Fix for Solaris 9/10 ld.so fun
    ... >>Slim chance, admittedly. ... >one, for that matter), but obviously I don't want to have either of ... Expressed in this posting are my opinions. ... to opinions held by my employer, Sun Microsystems. ...
    (comp.unix.solaris)
  • Re: boot time executables and shared libs
    ... This must only matter ... Expressed in this posting are my opinions. ... to opinions held by my employer, Sun Microsystems. ...
    (comp.unix.solaris)
  • Re: changing inode permissions
    ... They don't really matter. ... It's a bug, we know it's a bug, but for some reason it hasn't been ... Expressed in this posting are my opinions. ... to opinions held by my employer, Sun Microsystems. ...
    (comp.unix.solaris)
  • Re: Reintroducing myself.
    ... be persuaded away from certain key viewpoints, ... I am stating that you are arguing as academic discourse things ... There is also the small matter that - rightly or wrongly - ... sense that people might have actual opinions on the stuff which matter ...
    (rec.arts.sf.composition)