Email List: Xaustin-review-lX
[All Lists]

Defect in XSH Interaction of File Descriptors and Standard I/O Streams

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Defect in XSH Interaction of File Descriptors and Standard I/O Streams
From: yyyyyyy@xxxxxxxxxx
Date: Fri, 25 Jan 2002 06:24:42 GMT
        Defect report from : Ulrich Drepper , Red Hat, Inc.

(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)

@ page 36 line 1472ff section Interaction of File Descriptors and Standard I/O 
Streams objection {ud-ft-1}

Problem:

Defect code :  1. Error

This could be filed as an error in this section or an ommision in fflush().


The problem is that in section 2.5.1 of XSH, which deals with the interaction 
of file descriptors and I/O streams, it is written:

  If the stream is open with a mode that allows reading and the
  underlying open file description refers to a device that is capable
  of seeking, the application shall either perform an fflush( ), or
  the stream shall be closed.

The man page for fflush() explicitly does not mention what happens if fflush() 
is applied to an input stream or an update stream with the last operation being 
input.  This wording comes straight from ISO C.

The problem is that ISO C does not have to deal with file descriptors.  POSIX 
does.  In the early POSIX versions the text in section 2.5.1 was added to make 
clear how the interaction works.  But the fflush() documentation was never 
updated.


Action:

There are two possible options:

- the original intend was to define fflush() on input streams and it 
  was just forgotten to update the fflush() documentation.  In this
  case the page should be updated with the following in line 11607
  (CX shaded):

    If /stream/ points to an input stream or an update stream in which
    the most recent operation was not input, fflush() shall cause
    all buffered input to be discarded and on seekable files the file
    offset for the file descriptor be reset to the first unprocessed
    byte.


- if fflush() is not meant or cannot be changed some other mechanism
  for synchronizing input streams must be found.  As far as I can see
  no existing function fits the bill so I cannot make any concrete
  proposal.

<Prev in Thread] Current Thread [Next in Thread>
  • Defect in XSH Interaction of File Descriptors and Standard I/O Streams, drepper <=