home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.msdos.programmer
- Path: sparky!uunet!gatech!usenet.ins.cwru.edu!ncoast!brown
- From: brown@NCoast.ORG (Stan Brown)
- Subject: Re: question on spawning DOS from C prog
- Organization: Oak Road Systems, Cleveland Ohio USA
- Date: Thu, 7 Jan 1993 15:20:37 GMT
- Message-ID: <C0HpAD.Lny@NCoast.ORG>
- References: <1993Jan5.212229.57639@ns1.cc.lehigh.edu> <1iedifINNmoi@infoac.rmi.de> <tim.36.726368023@tim.src.utah.edu>
- Lines: 25
-
- In article <tim.36.726368023@tim.src.utah.edu> tim@tim.src.utah.edu (Tim Ma) writes:
- >>In your function declare something like:
- >> static char prompt[]="PROMPT=<Type EXIT to return to program>$_$_$P";
- >>and before the spawnl() do a
- >> putenv(prompt);
- [to display a custom prompt in a spawned DOS session]
-
- >Is this possible? It was my understanding that 'spawn' called a new command
- >shell so any changes in the environment would not be carried over.
-
- spawn does indeed call a new command shell. But the environment in that
- shell is a copy of the environment block of the program that created the
- shell. So the suggeted solution is the right thing to do: it modifies
- the prompt string in the program's copy of the environment, and then the
- spawned shell inherits the modified environment.
-
- When the user types EXIT to return from shell to program, and then later
- the program itself ends, the environment is unchanged because the putenv
- call modifies only the program's copy of the environment, not "the"
- envronment belonging to the original DOS shell at boot-up.
-
- The FAQ list sheds a little light on some related questions.
- --
- Stan Brown, Oak Road Systems brown@Ncoast.ORG
- Cleveland, Ohio, USA
-