public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: benko@sztaki.hu To: gcc-gnats@gcc.gnu.org Subject: libstdc++/6047: weird behaviour when reading from a pipe through an ifstream Date: Sat, 23 Mar 2002 01:16:00 -0000 [thread overview] Message-ID: <20020323090914.28476.qmail@sources.redhat.com> (raw) >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 <cstdio> #endif /* WORKAROUND */ #include <fstream> #include <iostream> 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 <enter> 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:
next reply other threads:[~2002-03-23 9:16 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-03-23 1:16 benko [this message] 2002-04-09 12:20 bkoz 2002-11-06 13:53 bangerth 2002-11-30 20:06 paolo
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020323090914.28476.qmail@sources.redhat.com \ --to=benko@sztaki.hu \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).