Date: Sun, 15 Aug 1999 12:54:57 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Edevaldo Pereira da Silva Junior cc: djgpp AT delorie DOT com Subject: Re: TCL Port to DJGPP - Bug + Advices. In-Reply-To: <37B4186B.9344D7CC@motorola.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Fri, 13 Aug 1999, Edevaldo Pereira da Silva Junior wrote: > I was thinking about using dup & dup2 to make the stderr point to a > tempfile then call "prog.exe" with system or popen. What I do not know > is how to make the stderr point to the right place again once the > prog.exe has finished. Any suggestions? The same as above: with dup and dup2. You use dup to save the original stderr in a variable, then, when the child program exits, use dup2 to force stderr to point to the same handle as the one you saved with dup. For examples of how this is done, look in the sources of `system' and `popen' in the DJGPP library. They do it for stdout, not stderr, but this difference is not important. > Another question: Regarding file descriptors, is it usual that the > descriptors 0,1 & 2 will always point to stdin,stdout & stderr > respectively? I believe this is Posix-standard, but I'm not sure. > Is it standard across platforms? I'd guess that many C programs would be badly broken if this was not the case. However, you shouldn't usually need to rely on this.