www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/06/22:42:34

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: STDERR
Date: Wed, 06 Nov 1996 20:46:06 -0800
Organization: Three pounds of chaos and a pinch of salt
Lines: 49
Message-ID: <3281698E.63A5@cs.com>
References: <327FE3E5 DOT 86A AT cyberramp DOT net> <55q377$boj AT top DOT mitre DOT org>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp225.cs.com
Mime-Version: 1.0
To: Michael F Brenner <mfb AT mbunix DOT mitre DOT org>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Michael F Brenner wrote:
> 
> While djgpp does come with a program that redirects stderr, it
> works as a shell around your program and it does not transmit
> the condition code produced by your program. So the full answer
> to your question is that there is no satisfactory way to
> redirect STDERR, and we must simply wait until the unfortunate
> decision to give the user no control over where the errors are
> written to, is changed. This decision took effect with version
> 2.0 of djgpp. STDERR sounds like the right place to put error
> messages, but the tools have not yet been programmed to work
> with STDERR, such as a tool to redirect while keeping the
> condition code of the program whose STDERR is being redirected.
> The simplest solution would be for someone who knows how to do it
> to post the code needed to capture the true condition code of
> a child executable while redirecting the child's STDERR to a file
> or to the console through STDOUT where we can use DOS redirection
> (the > sign) to put it to a file. Until someone does this work,
> you have to wait for each compile with your hand close to the
> PAUSE button on your keyboard. It helps to put the screen in
> 50-line mode, so you have an extra fraction of a second to get
> to the PAUSE button.

I don't quite understand your problem here:  why is the gcc return code
so important?  If you need it with Make, you can simply invoke the
entire program tree with redir. (i.e., redir [options] make ...)

For programs that spawn other programs, there are ways to play with the
file descriptors that will cause the streams to be redirected the way
you want them to.  Difficult and somewhat messy, but not impossible.

As far as invoking from DOS is concerned, the only way to capture stderr
is to use redir, as DOS doesn't support stderr redirection, period.  You
can try a smarter shell such as 4DOS if you want.

Finally, if you are really so concerned about redir preserving the exit
code of the program, why not get the sources (in djlsr201.zip) and
change its behavior yourself?  If you can come up with a workable
alternative, I am sure the DJGPP team would be willing to include it.

-- 
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>+ W++ N++ o+ K? w(---) O-
M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+ tv+() b+++ DI++ D++ G e(*)>++++
h!() !r !y+()
------END GEEK CODE BLOCK------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019