Mail Archives: djgpp/1997/09/05/12:48:37
On Wed, 3 Sep 1997 19:00:28 GMT, fredex AT fcshome DOT stoneham DOT ma DOT us (Fred
Smith) wrote:
> On MSDOS >= 3.x, argv[0] is generally the full pathname of the program
> being run, which is either what you typed when you ran it, or based
> on a PATH search if you did not specify the absolute location. On
> earlier systems argv[0] may be empty (I'm not sure). When run on
> Windoze I've no idea what argv[0] is. Unix platforms generally do
> not put the full pathname in argv[0], so you've got to make assumptions.
> One thing you can do is to search the PATH environment, but that for
> sure is not robust (what if you have a program named FOO in the path,
> but you instead ran a different program, from a different directory,
> of the same name??)
Section 12.1 of the DJGPP FAQ says:
| Note that the `argv[0]' parameter under the debugger is *not* the full
| pathname of the debuggee, so programs which use `argv[0]' for their
| operation might behave differently under a debugger.
There's also something about stubedit and argv[0] in section 22.3.
I think that if the program was started by one of the spawn/exec
functions, it gets the contents of the argv0 parameter from the spawn
functions, and that doesn't have to be anything meaningful.
Hmm, tried it with
execlp("../c/argv0.exe", "something", "arg1", "arg2", 0);
=> the called program has "../c/argv0.exe" as its argv[0], "something"
is discarded.
execlp("argv0", "something", "arg1", "arg2", 0);
=> the called program has "argv0.exe" as its argv[0], no path at all.
Regards...
Michael
- Raw text -