🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #431

I/O redirection in DOS

#431
From: Fred Smith
Date: Tue, 12 Dec 1989 14:11
30 lines
1225 bytes
Yesterday I posted a plea for help with an I/O redirection problem. Well,
last night I figured out what was the correct way to do it, so if any of you
were planning to reply, I thank you, but it is not necessary now!


Anyhow, for posterity's sake, what I needed to do was temporarily DISABLE
existing redirection of stdin when spawning a child process, and then
reenable the redirection after the child process exited. Here is a sketch
of what I ended up doing, which seems to be just fine:


int old;
FILE *new;

old = dup (fileno (stdin));
new = fopen ("CON", "r");
dup2 (fileno(new), fileno (stdin));

/* stuff here to do the child shell */


dup2(old, fileno(stdin));
fclose (new);


(Of course, I can't claim all the credit--I had a bit of help from Ray Duncan's
book Adavnced MSDOS!!!!!!!!)

Fred Smith
Technical Details
Message-ID: <8163@cg-atla.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!samsung!cg-atla!fredex

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!samsung!cg-atla!fredex
From: fredex@cg-atla.UUCP (Fred Smith)
Newsgroups: alt.msdos.programmer,comp.sys.ibm.pc
Subject: I/O redirection in DOS
Message-ID: <8163@cg-atla.UUCP>
Date: 12 Dec 89 14:11:00 GMT
Reply-To: fredex@cg-atla.UUCP (Fred Smith)
Organization: Agfa Compugraphic Division
Lines: 30