This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
ios::app and pipes
- From: Dimitri Papadopoulos <papadopo at REMOVE dot shfj dot DECOY dot cea dot fr>
- To: libstdc++ at gcc dot gnu dot org
- Date: Fri, 08 Nov 2002 14:26:52 +0100
- Subject: ios::app and pipes
- Organization: SHFJ
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