Article View: comp.os.msdos.programmer
Article #7520Re: question on spawning DOS from C prog
From: Chris Fortier
Date: Fri, 08 Jan 1993 00:59
Date: Fri, 08 Jan 1993 00:59
51 lines
2013 bytes
2013 bytes
In article <1993Jan7.140524.15787@ns1.cc.lehigh.edu> jmt7@ns1.cc.lehigh.edu (JOHN M. TROIANO) writes:
[ STUFF DELETED ]
Hi, I am the original poster of this problem: this is especially to
Tim and Wolfgang. I tried the code below (which is I think what both
of you guys are suggesting) but it does'nt work (the new prompt
string is ignored). Any ideas? - John.
#include <stdio.h>
#include <process.h>
#include <dos.h>
#include <stdlib.h>
int main( int argc, char *argv[], char **envp )
{
printf( "\ninside main, spawning DOS\n" );
sleep( 2 );
putenv( "prompt=$_type EXIT to return to program $_$_$p$g" );
spawnlpe( P_WAIT, "command.com", NULL, envp );
printf( "\nback from spawn!\n" );
sleep( 2 );
}
Sigh. Please RTFM. The third parameter to spawn???() is argv[], a list of
parameters to the spawned executable. This means that argv[0] must be the
name of the executable. I know this seems redundant, but it does have a
purpose (changing path information, passing info to the child program, etc.).
Change the spawn???() command to the following, and the program should work:
spawnlpe(P_WAIT, "command.com", "command.com", NULL, envp);
^ ^
| |
path argv[0]
Chris Fortier
Borland C++ Run Time Library QA
cfortier@borland.com
Technical Details
Message-ID:
<CFORTIER.93Jan7165941@genghis.news>Path:
arc1-ca.pugleaf.net!sparky!uunet!wupost!csus.edu!borland.com!news!cfortierReferences:
<1993Jan7.140524.15787@ns1.cc.lehigh.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!csus.edu!borland.com!news!cfortier From: cfortier@genghis.news (Chris Fortier) Subject: Re: question on spawning DOS from C prog In-Reply-To: jmt7@ns1.cc.lehigh.edu's message of 7 Jan 93 14:05:24 GMT Message-ID: <CFORTIER.93Jan7165941@genghis.news> Sender: news@borland.com (News Admin) Organization: Borland International, Inc. References: <1993Jan7.140524.15787@ns1.cc.lehigh.edu> Date: Fri, 8 Jan 1993 00:59:41 GMT Lines: 51