This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

ios::app and pipes


Hi,

fstream::open() with ios::app flag has not been working with
pipes since gcc 3.0. This can be reproduced at least on:
- Solaris 8 7/01 + gcc 3.2
- IRIX 6.5.13 + gcc 3.0.2

ios:app used to work fine with pipes in gcc 2.95.3.

To reproduce:
- build the attached openapp.cc source file
- create a pipe named /tmp/pipe
- run the program, it will attempt to open the pipe with ios::app
- read the pipe from the shell to unblock - use "cat /tmp/pipe"
- fstream::open() will fail with error "Illegal seek"

Is this a known issue? Is this expected?

Regards,
Dimitri
#include <iostream>
#include <fstream>
#include <cstring>
#include <cerrno>

using namespace std;

int main() {
  ofstream pipe;
  pipe.open( "/tmp/pipe", ios::out|ios::app );
  if( !pipe )
    cerr << "could not open pipe (" << errno << ", " << strerror(errno) << ")" << endl;
}
CCC=g++
RM=rm -f
MKFIFO=mkfifo

all: openapp

openapp: openapp.o
	$(CCC) -o openapp openapp.o

openapp.o: openapp.cc
	$(CCC) -c openapp.cc

run: openapp
	$(MKFIFO) /tmp/pipe
	./openapp
	$(RM) /tmp/pipe

clean:
	$(RM) openapp openapp.o

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