Mail Archives: djgpp/1996/03/11/09:43:43
Xref: | news2.mv.net comp.os.msdos.djgpp:1780
|
Newsgroups: | comp.os.msdos.djgpp
|
From: | paul AT pact DOT srf DOT ac DOT uk (Paul Stallard)
|
Subject: | system() redirection bug
|
Message-ID: | <DnsEn7.A4s@uns.bris.ac.uk>
|
Sender: | usenet AT uns DOT bris DOT ac DOT uk (Usenet news owner)
|
Nntp-Posting-Host: | pomerol.pact.srf.ac.uk
|
Organization: | University of Bristol, England
|
Date: | Tue, 5 Mar 1996 09:06:43 GMT
|
Lines: | 47
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I've come across a bug in the redirection of output from system()
calls. Has anyone seen this before, and is there a fix available? To
see the problem, you need two simple programs:
/*--------- a.c --------- */
#include <stdlib.h>
#include <stdio.h>
int main() {
printf("Hello from a\n");
system("b > bbb\n");
}
/*------ end of a.c ------*/
/*--------- b.c --------- */
#include <stdio.h>
int main() {
printf("Hello from b\n");
}
/*------ end of b.c ------*/
If you run
c:\> a
then the expected happens: "Hello from a" is printed on the terminal and
"Hello from b" appears in bbb. However, if you run
c:\> a > aaa
you expect "Hello from a" to appear in aaa, and "Hello from b" in bbb.
In fact, aaa is empty and bbb contains both lines. This program works
fine under V1. The same bug also appears if you execute
system("a > aaa");
in a third program (which is the situation in which I actually
encountered the problem).
Thanks for any help you can give me on this,
Paul
------------------------------------------------------------------------------
Paul Stallard | Email: paul AT pact DOT srf DOT ac DOT uk
Department of Computer Science | Tel: +44 117 970 7196
University of Bristol, 10 Priory Road, | FAX: +44 117 970 7171
Clifton, Bristol, BS8 1TU, United Kingdom | http://www.pact.srf.ac.uk/~paul/
- Raw text -