Mail Archives: djgpp/1993/12/07/12:13:10
On Tue, 7 Dec 1993, DJ Delorie wrote:
> > /* DODAT.C */
> > #include <stdlib.h>
> > void main(int argc, char *argv[])
> > {
> > execv("DOIT.EXE", argv[]); /* or another flavor of exec() */
> > }
> >
> > DOIT.EXE will see that argv[0] = "DODAT.EXE", won't it? This seems to
>
> No. argv[0] is *always* set from the program name in MS-DOS,
> regardless of what you pass for exec*. DJGPP bypasses MS-DOS in order
> to provide this functionality, so if you were using a djgpp program to
> call another djgpp program (via exec*), the argv array is passed
> intact. Note, however, that it's much more efficient to use the
> symbolic link mechanism that djgpp provides instead.
>
If I am following this, you are saying this WILL work between programs
compiled with DJGPP. For example:
/* DOIT.C */
void main(int argc, char *argv[])
{
printf("%s\n", argv[0]);
}
would print DOIT.EXE when invoked from the DOS prompt, and DODAT.EXE when
it is execv'd in the DODAT.C program. (??)
But, if you invoke, say, a program compiled with BCC (or other)
execl("mybccprg.exe", "yomama.exe", "arg1", "another arg", 0);
it would call mybccprg.exe with argv[0] = "mybccprg.exe", instead of
"yomama.exe" (??). Kinda like
system("yomama.exe arg1 'another arg'");
Thanks DJ,
Ed
(in high density brain fog, low sleep mode)
/***************************************************************************/
/* Ed Phillips flaregun AT brahms DOT udel DOT edu University of Delaware */
/* Jr Systems Programmer (302) 831-6082 NSS/Software Systems */
/***************************************************************************/
- Raw text -