Article View: alt.msdos.programmer
Article #430I/O redirection in DOS
From: Fred Smith
Date: Tue, 12 Dec 1989 13:48
Date: Tue, 12 Dec 1989 13:48
30 lines
1213 bytes
1213 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:
<8160@cg-atla.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!cg-atla!fredexShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!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: <8160@cg-atla.UUCP> Date: 12 Dec 89 13:48:21 GMT Reply-To: fredex@cg-atla.UUCP (Fred Smith) Organization: Agfa Compugraphic Division Lines: 30