Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!ssbell!mcmi!amperif!unocss!ho@fergvax.unl.edu From: ho@fergvax.unl.edu (Michael Ho) Newsgroups: comp.sys.ibm.pc Subject: Re: MS-DOS puzzle #1 Message-ID: <1065@unocss.UUCP> Date: 11 Jul 89 15:09:22 GMT References: <8167@bsu-cs.bsu.edu> Sender: news@unocss.UUCP Reply-To: ho@fergvax.unl.edu Lines: 29 From article <8167@bsu-cs.bsu.edu>, by dhesi@bsu-cs.bsu.edu (Rahul Dhesi): > > In article <6893@bsu-cs.bsu.edu> a long time ago I wrote: >> >> Question: Why does COMMAND.COM allow redirection of standard >> input and standard output, but not standard error? >> >> Answer: MS-DOS, unlike UNIX, doesn't have a fork() system call; >> therefore the MS-DOS command interpreter, unlike the >> UNIX shell, can't redirect standard error. >> >>THE PUZZLE. Does the above make any sense? If it does, why? If it >>does not, what is the real answer to the question? >> Why can't MS-DOS just redirect all three file handles, and after the command is complete, do this: close(2); open ("CON", O_WRITE); { this could be wrong; I haven't done fdup (2, 1); medium-level I/O in a while } close (0); open ("CON", O_READ); After all, CON is like /dev/tty in Unix, isn't it? It's always there, and never goes away. Any program which wants a piece of the terminal can open CON, so why not COMMAND? Or am I just being naive? --- ... Michael Ho, University of Nebraska