home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libc / nfclose.c < prev    next >
C/C++ Source or Header  |  1988-12-11  |  518b  |  24 lines

  1. /*
  2.  * nfclose(stream) - flush the stream, fsync its file descriptor and
  3.  * fclose the stream, checking for errors at all stages.  This dance
  4.  * is needed to work around the lack of Unix file system semantics
  5.  * in Sun's NFS.  Returns EOF on error.
  6.  */
  7.  
  8. #include <stdio.h>
  9.  
  10. int
  11. nfclose(stream)
  12. register FILE *stream;
  13. {
  14.     register int ret = 0;
  15.  
  16.     if (fflush(stream) == EOF)
  17.         ret = EOF;
  18.     if (fsync(fileno(stream)) < 0)        /* may get delayed error here */
  19.         ret = EOF;
  20.     if (fclose(stream) == EOF)
  21.         ret = EOF;
  22.     return ret;
  23. }
  24.