Contents of argv[0]
Conor P. Cahill
cpcahil at virtech.UUCP
Wed Aug 16 12:25:24 AEST 1989
In article <10094 at csli.Stanford.EDU>, gandalf at csli.Stanford.EDU (Juergen Wagner) writes:
> The first argument to aqn execl is the path name of the program to be
> executed. The arguments starting with the second are what the program will
> get as an argv[]. This effectively means that in general, argv[0] cannot
> be treated as a reliable source for the path name! [RTFM]
>
I did RTFM many times for many flavors of unix for many of the past years.
What I ment to say was "argv[0] will NORMALLY contain the path". The example
was not meant to say that argv[0] would have the first argument of the execl().
The example "the first argument to an execl()" was an example for the path
used to execute the program..
> You have to distinguish between features provided by UNIX (in general) and
> some UNIX (in particular). The execve system call makes it quite clear that
> there doesn't have to be any relation whatsoever between the pathname of the
> program being invoked and the argument vector argv[]. Check the man page for
> execve().
My intent was to say that argv[0] will normally contain a path, but to be
portable the code should handle anything (hence the sample for MSC).
More information about the Comp.lang.c
mailing list