This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/5799: streams reading from fifo



>Number:         5799
>Category:       libstdc++
>Synopsis:       streams reading from fifo
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 01 02:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Benko Pal
>Release:        3.0.4
>Organization:
>Environment:
SuSE linux 7.3 i686 libc 2.2.4
>Description:
Perhaps this is not a bug.

if an ifstream reads from a named pipe, it sees the data
only when the buffer is full or the pipe is closed, but not
when the process writing to the pipe flushes.  Using
<stdio.h> there is no such problem.

e.g. compiling and running

#include <fstream>
#include <iostream>


int
main()
{
  std::ifstream in("/tmp/pipe");
  char          c;

  while (in >> c)
    std::cout << c;
  
  return 0;
}

while in an other shell I

$ mkfifo /tmp/pipe
$ cat > /tmp/pipe
hello
world
^D
$

In the shell running the c++ program
helloworld
only appears after ^D.


But compiling and running

#include <stdio.h>


int
main()
{
  FILE *in = fopen("/tmp/pipe", "r");
  char c;

  while ((c = fgetc(in)) != EOF)
    putchar(c);

  return 0;
}

After entering hello and pushing enter, hello appears
on the output of the program.

Is a special initialisation of the ifstream needed perhaps?
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]