🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #5620

Re: Spawning processes in DOS

#5620
From: Marc Brandis
Date: Thu, 04 Apr 1991 11:08
34 lines
2066 bytes
In article <1991Apr3.133226.22304@ibmpa.awdpa.ibm.com> dougs@claude1.rchland.ibm.com (J Doug Smith) writes:
>I'm trying to write an application that will run another program and get that
>program's output so it can be displayed to the user (much like an editor runs
>a compiler and sends the compiler's output to the user).  Does anyone have any
>Ideas on how to accomplish this?  
>Execing another programs certainly is no problem, I just don't see how to 
>get the output from that program.


Redirect your stdout handle to a temporary file. The process your are
exec'ing inherits the handles from the parent process, which is your program.
After the program terminates, restore your stdout handle and read the output
from the temporary file.

The steps to redirect are about as follows (I never did it myself, but this is
the way it should work):

	- duplicate stdout handle to temp (required for later restore)
	- close stdout
	- open temporary file, it will get the stdout handle 1 assigned
	- exec the program
	- close temporary file (which is stdout)
	- duplicate temp handle to stdout
	- close temp handle
	- open temporary file in order to read the programs output


Marc-Michael Brandis
Computer Systems Laboratory, ETH-Zentrum (Swiss Federal Institute of Technology)
CH-8092 Zurich, Switzerland
email: brandis@inf.ethz.ch


------------------------------ End of forwarded message 1
Technical Details
Message-ID: <27844@neptune.inf.ethz.ch>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!chx400!bernina!neptune!inf.ethz.ch!brandis
References: <1991Apr3.133226.22304@ibmpa.awdpa.ibm.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!chx400!bernina!neptune!inf.ethz.ch!brandis
From: brandis@inf.ethz.ch (Marc Brandis)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Spawning processes in DOS
Message-ID: <27844@neptune.inf.ethz.ch>
Date: 4 Apr 91 11:08:01 GMT
Article-I.D.: neptune.27844
References: <1991Apr3.133226.22304@ibmpa.awdpa.ibm.com>
Sender: news@neptune.inf.ethz.ch
Reply-To: brandis@inf.ethz.ch (Marc Brandis)
Organization: Departement Informatik, ETH, Zurich
Lines: 34