This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/30162] [4.7/4.8 Regression] I/O with named pipes does not work on Darwin
- From: "tkoenig at netcologne dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 18 Feb 2013 21:24:31 +0000
- Subject: [Bug libfortran/30162] [4.7/4.8 Regression] I/O with named pipes does not work on Darwin
- Auto-submitted: auto-generated
- References: <bug-30162-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30162
--- Comment #47 from tkoenig at netcologne dot de <tkoenig at netcologne dot de> 2013-02-18 21:24:31 UTC ---
Am 18.02.2013 21:16, schrieb jb at gcc dot gnu.org:
>> Look at this piece of code:
>> >
>> > /* Seek to the head and overwrite the bogus length with the real
>> > length. */
>> >
>> > if (unlikely (sseek (dtp->u.p.current_unit->s, - m - 2 * record_marker,
>> > SEEK_CUR) < 0))
>> > goto io_error;
>> >
>> >This works if it happens within a buffer, but you cannot rely on that.
>> >
>> >I would therefore suggest to resolve this PR by issuing a well-defined
>> >error if we encounter a pipe on opening.
>> >
>> >I'll prepare a patch.
> As I explained in comment #23, this is already handled. When opening a file, we
> stat() the fd, and use the buffered I/O functions only if it's a regular file,
> otherwise the unbuffered raw I/O functions are used.
This is part of the precipitate, not part of the solution ;-)
For unformatted sequential, we first write a dummy record marker, write
the data and the final record marker, then seek to the first marker
and re-write that. Of course, this fails for an unbuffered fifo.
If we want this to work, we should make sure we always use
_buffered_ I/O for unformatted sequential, setting a maximum
record length on open that we can handle with our buffer.