(libc.info.gz) Error Recovery

Info Catalog (libc.info.gz) EOF and Errors (libc.info.gz) I/O on Streams (libc.info.gz) Binary Streams
 
 12.16 Recovering from errors
 ============================
 
 You may explicitly clear the error and EOF flags with the 'clearerr'
 function.
 
  -- Function: void clearerr (FILE *STREAM)
      Preliminary: | MT-Safe | AS-Safe | AC-Unsafe lock |  POSIX
      Safety Concepts.
 
      This function clears the end-of-file and error indicators for the
      stream STREAM.
 
      The file positioning functions ( File Positioning) also
      clear the end-of-file indicator for the stream.
 
  -- Function: void clearerr_unlocked (FILE *STREAM)
      Preliminary: | MT-Safe race:stream | AS-Safe | AC-Safe | 
      POSIX Safety Concepts.
 
      The 'clearerr_unlocked' function is equivalent to the 'clearerr'
      function except that it does not implicitly lock the stream.
 
      This function is a GNU extension.
 
    Note that it is _not_ correct to just clear the error flag and retry
 a failed stream operation.  After a failed write, any number of
 characters since the last buffer flush may have been committed to the
 file, while some buffered data may have been discarded.  Merely retrying
 can thus cause lost or repeated data.
 
    A failed read may leave the file pointer in an inappropriate position
 for a second try.  In both cases, you should seek to a known position
 before retrying.
 
    Most errors that can happen are not recoverable -- a second try will
 always fail again in the same way.  So usually it is best to give up and
 report the error to the user, rather than install complicated recovery
 logic.
 
    One important exception is 'EINTR' ( Interrupted Primitives).
 Many stream I/O implementations will treat it as an ordinary error,
 which can be quite inconvenient.  You can avoid this hassle by
 installing all signals with the 'SA_RESTART' flag.
 
    For similar reasons, setting nonblocking I/O on a stream's file
 descriptor is not usually advisable.
 
Info Catalog (libc.info.gz) EOF and Errors (libc.info.gz) I/O on Streams (libc.info.gz) Binary Streams
automatically generated by info2html