From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2352 invoked by alias); 23 Mar 2002 09:16:05 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 2324 invoked by uid 71); 23 Mar 2002 09:16:01 -0000 Resent-Date: 23 Mar 2002 09:16:01 -0000 Resent-Message-ID: <20020323091601.2323.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, benko@sztaki.hu Received:(qmail 28477 invoked by uid 61); 23 Mar 2002 09:09:14 -0000 Message-Id:<20020323090914.28476.qmail@sources.redhat.com> Date: Sat, 23 Mar 2002 01:16:00 -0000 From: benko@sztaki.hu Reply-To: benko@sztaki.hu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/6047: weird behaviour when reading from a pipe through an ifstream X-SW-Source: 2002-03/txt/msg00872.txt.bz2 List-Id: >Number: 6047 >Category: libstdc++ >Synopsis: weird behaviour when reading from a pipe through an ifstream >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sat Mar 23 01:16:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Benko Pal >Release: 3.0.4 >Organization: >Environment: i686, SuSE 7.3, glibc 2.2.4 >Description: When two programs communicate through fifos and handles them with std::fstreams, then flushing on the writing side does not make the contents appear on the reading side. The reading side only sees the data when the writing buffer is overrun or the writing side closes the buffer. A test case: ------------------------------------------ #ifdef WORKAROUND # include #endif /* WORKAROUND */ #include #include int main() { #ifdef WORKAROUND std::filebuf b(std::fopen("/tmp/pipe", "r"), std::ios_base::in, 1); std::istream in(&b); #else /* ! WORKAROUND */ std::ifstream in("/tmp/pipe"); #endif /* WORKAROUND */ char c; while (in.get(c)) std::cout.put(c); return 0; } ------------------------------------------- In an other shell do $ rm -f /tmp/pipe $ mkfifo /tmp/pipe $ cat > /tmp/pipe hallo world ^D $ If the program above is compiled with 3.0.*, and run, then "hallo" and "world" appear together, after ^D is pressed in the writing shell. Compiling with 2.95.3, "hallo" appears when I hit in the writing shell, separately from "world", so this is a sort of regression. An equivalent C program behaves like 2.95.3, compiled with either compiler. This behavior is very important for me, without this the two programs just keep waiting for each other. By defining WORKAROUND I get the expected result, but it's a bit inconvenient to initialise a stream like this. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: