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]

[Fwd: Re: libstdc++/8504: ios::app + pipes]


Here are some more details.


Running my example in the debugger I found that the relevant code in
source file libstdc++-v3/config/io/basic_file_stdio.cc from gcc 3.2
looks like:

115 __basic_file<char>* 116 __basic_file<char>::open(const char* __name, ios_base::openmode __mode, 117 int /*__prot*/)
118 {
[...]
128 if ((_M_cfile = fopen(__name, __c_mode)))


In an attempt to reproduce the problem, I've written the following code:

#include <stdio.h>
int main() {
if (!fopen("/tmp/pipe", "a"))
perror("/tmp/pipe");
}


This code fails on Solaris and IRIX. It succeeds on Linux:

$ uname -sr
SunOS 5.8
$ g++ -v
Reading specs from /usr/local/gcc/bin/../lib/gcc-lib/sparc-sun-solaris2.8/3.2/specs
Configured with: ../gcc-3.2/configure --prefix=/usr/local/gcc-3.2 --with-as=/usr/local/binutils/bin/as --with-ld=/usr/local/binutils/bin/ld
Thread model: posix
gcc version 3.2
$ g++ -g -o foo foo.cc
$ ./foo
/tmp/pipe: Illegal seek
$
$ uname -sr
Linux 2.4.18-14
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 200020903 (Red Hat Linux 8.0 3.2-7)
$ g++ -g -o foo foo.cc
$ ./foo
$
So it's really a question of fopen(..., "a") not working on pipes on
Solaris and IRIX. Somehow gcc 2.95.3 used to work around this issue.

Regards,
--
Dimitri


http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8504



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