Article View: alt.msdos.programmer
Article #1156Re: Redirection of STDERR ??
From: Bubba Joe
Date: Tue, 28 Nov 1995 00:35
Date: Tue, 28 Nov 1995 00:35
40 lines
1741 bytes
1741 bytes
In article <49bt2q$sl3@bagan.srce.hr>, dcarapic@fly.cc.fer.hr says...
>
>Raymond Moon (raymoon@moonware.dgsys.com) wrote:
>: Fred (Frot) wrote:
>
>: > At the moment I am developing some kind of tool to call (spawn/exec)
>: > other commands (using swap of memory) in MS-DOS.
>: >
>: > In order not to disturb the screen by messages from the called
program
>: > I use redirection of stdout.
>: >
>: > e.g. 'dir > \it.txt'
>: >
>: > I encountered a problem when this called program writes something to
>: > stderr. These messages are not redirected to the file, but corrupt
the
>: > screen display and confuse the ignorant user.
>: >
>
>'>' redirects stdout but it doesn't redirect stderr try '>&' (it's been a
>long time so i'm not sure if this works)
Inside your code, before you execute your spawn or exec, try the
following:
close(2);
or
fclose(stderr); /* Assuming <stdio.h> */
I tested this with MSVC++ 1.5 (though I used the "system" function)
and it seemed to work okay. If you actually want to keep stderr available
for your use, you can dup or dup2 it, then close it, and re-dup or dup2
it.
Fred
Technical Details
Message-ID:
<49dlhd$15a@news.ro.com>Path:
arc1-ca.pugleaf.net!news.ro.com!usenetReferences:
<DI3BnA.JF5@news.zippo.com> <30AE81F4.54D@moonware.dgsys.com> <49bt2q$sl3@bagan.srce.hr>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.ro.com!usenet From: you@somehost.somedomain (Bubba Joe) Newsgroups: alt.msdos.programmer,comp.lang.c,comp.msdos.programmer,comp.os.msdos.programmer Subject: Re: Redirection of STDERR ?? Date: 28 Nov 1995 00:35:57 GMT Organization: Your Organization Distribution: world Message-ID: <49dlhd$15a@news.ro.com> References: <DI3BnA.JF5@news.zippo.com> <30AE81F4.54D@moonware.dgsys.com> <49bt2q$sl3@bagan.srce.hr> NNTP-Posting-Host: ts2p15.ro.com Mime-Version: 1.0 X-Newsreader: WinVN 0.99.3