11-26-05 07:50 AM
Lew Pitcher <lpitcher@sympatico.ca> writes:
>
> Nope. The file parameter is (in effect) used by the loader to load the bin
ary,
> but the argv[] parameter is (in effect) used by the linker to pass inf
ormation
> to the running binary.
Huh? Which linker are you talking about?
After the program is running, linker is not involved *at all*.
The runtime loader is involved, but it doesn't care about agrv[0]
on any UNIX I know.
> While the manpage says to give the filename as argv[0], consider that
some
> times it is useful to pass other information as argv[0]. For instance
,
>
> argv[0] = "-";
> argv[1] = NULL;
> execvp("/bin/bash",argv);
>
> Take a look at your login shell through ps. See the similarity?
So you've just confirmed that argv[0] does *not* need to be the
file name, contradicting your own earlier "Nope" statement.
Yes, exec()ed programs themselves could well care about values
of argv[0], argv[1], etc. They could also care about time of day,
or values of environment variables. But none of this is "required
to execute the program" (i.e. exec() it and get it to its entry
point).
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
[ Post a follow-up to this message ]
|