Problem with gfortran and named pipes under unix

Jerry DeLisle jvdelisle@verizon.net
Tue Dec 12 05:36:00 GMT 2006


Jerry DeLisle wrote:
> Bud Davis wrote:
>> --- Johannes Lotz <johannes.lotz@rwth-aachen.de>
>> wrote:
>>
>>> Hello.
>>>
>>> I have a problem using gfortran for a code dealing
>>> with named pipes.
> 
> 
>>
>>
>> Which looks to me like an error both on the writing
>> and the reading.
>>
>> Could you please try the above example, and if
>> possible simplify it a bit more...if this demonstrates
>> your problem, then file a bugzilla report.
>>
> I have tried this here and can confirm the hangups.  We are going to 
> have to study this a bit.  I have not used named pipes myself much.
> 
> Jerry
> 
This snippet id from libgfortran/io/unix.c

   /* non-seekable files, like terminals and fifo's fail the lseek.
      Using ftruncate on a seekable special file (like /dev/null)
      is undefined, so we treat it as if the ftruncate succeeded.
   */
#ifdef HAVE_FTRUNCATE
   if (s->special_file || ftruncate (s->fd, s->logical_offset))
#else
#ifdef HAVE_CHSIZE
   if (s->special_file || chsize (s->fd, s->logical_offset))
#endif
#endif
     {
       s->physical_offset = s->file_length = 0;
       return SUCCESS;
     }

Further examination of unix.c reveals lseek being used in fd_flush, 
fd_alloc_r_at, fd_alloc_w_at.  We do have a helper function to test that a 
stream is seekable.  I think we need to incorporate this into those functions so 
that we handle this correctly.  If a stream is not seekable, then just allocate 
the next portion of the stream the number of bytes requested.

I opened PR 30162 for this.

Jerry



More information about the Fortran mailing list