home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.programmer:5753 comp.unix.questions:14861
- Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!smurf.sub.org!easix!umunk!udo
- From: udo@umunk.GUN.de (Udo Munk)
- Followup-To: comp.unix.programmer,comp.unix.questions
- Newsgroups: comp.unix.programmer,comp.unix.questions
- Distribution: world
- Subject: Re: Programs that fork() don't redirect output in desired way?
- X-Newsreader: TIN [version 1.1 PL7]
- References: <941@ncrsaud.SaudiArabia.NCR.COM>
- Message-ID: <9212211155@umunk.GUN.de>
- Organization: Udo Munk's private BBS
- Date: Mon, 21 Dec 92 11:44:58 GMT
- Lines: 16
-
- Khalid Bahey-elDin (kbahey@ncrsaud.SaudiArabia.NCR.COM) wrote:
- [...]
- : The problem is that the file does not contain things in chronological order.
- : What happens is that it will contain output from the parent, then output from
- : child1, then output from child2, all interspersed.
- :
- : I assume this is because of system buffering for printf()s.
- :
- : Of course I can rewrite the printf()s so as they would write to a special log
- : file, but this would be a considerable effort, plus it will deprive us of the
- : flexibility of displaying output directly to the terminal when we want to.
- :
- : What is an easy way to get the output of all three processes correctly in
- : correct chronological order?
-
- Add a fflush(stdout) after each printf().
- --
- Udo Munk, Oberstr. 21, 4040 Neuss 1, Germany
- udo@umunk.GUN.de ...!{mcshh,smurf,unido}!easix!umunk!udo CIS: 100021,2515
- uucp: +49 2131 278869 V22/32/42bis 8N1 login: uucp pwd: public MYNAME=bbsuser
- request file /usr/spool/uucppublic/info for instructions
-