home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / programm / 5753 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.6 KB

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