home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / ultrix / 5977 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  2.0 KB

  1. Xref: sparky comp.unix.ultrix:5977 comp.lang.c:11768
  2. Newsgroups: comp.unix.ultrix,comp.lang.c
  3. Path: sparky!uunet!haven.umd.edu!decuac!hussar.dco.dec.com!mjr
  4. From: mjr@hussar.dco.dec.com (Marcus J. Ranum)
  5. Subject: Re: File Buffering Problem
  6. Message-ID: <1992Jul30.170828.369@decuac.dec.com>
  7. Sender: news@decuac.dec.com (USENET News System)
  8. Nntp-Posting-Host: hussar.dco.dec.com
  9. Organization: Digital Equipment Corporation, Washington ULTRIX Resource Center
  10. References: <13173.2a77e2b1@ohstpy.mps.ohio-state.edu>
  11. Date: Thu, 30 Jul 1992 17:08:28 GMT
  12. Lines: 31
  13.  
  14. >I have written a C program on a DecStation 5000 series running Ultrix 4.2A.
  15. >I am using GnuC 1.37 but could use the Dec cc or c89 if I had to.  The program
  16. >runs for a long time (min 15 hrs.) and writes log files during its run.
  17. >It's not uncommon that the program will hang requiring a Ctrl-C to end it or
  18. >that I want to see its progress by looking at the log files.
  19.  
  20.     If the program hangs, and you use ^C to end it, there are two better
  21. ways to diagnose the hang. One is to run the program under a debugger and
  22. when it hangs, stop it and see what's going on in there. Another is to kill
  23. it with a signal that causes a core dump, and then examine the core file
  24. with a debugger to see where it was when it hung.
  25.  
  26. >A. I have tried using the fflush(stream) function but apparently this only
  27. >   flushes the C file buffer and not the Ultrix one since nothing gets written.
  28.  
  29.     fflush(stream) will flush the disk buffers. If it doesn't, your
  30. application is doing something weird. fflush()'s behavior is well documented
  31. and well tested:
  32.      The fflush routine causes any buffered data for the named
  33.      output stream to be written to that file.  If stream is
  34.      NULL, all open output streams are flushed.  The stream
  35.      remains open.
  36.     Believe me, if fflush() didn't work as advertised, there would be a
  37. lot of broken code.
  38.  
  39. >C. Is there any way to force piping output to get flushed as it's being
  40. >   written?
  41.  
  42.     Put a call to "tee" in the pipe as a diagnostic tool.
  43.  
  44. mjr.
  45.