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