home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.internals
- Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!bradley.bradley.edu!cs1!alchemy
- From: alchemy@cs1.bradley.edu (Mike Swiston)
- Subject: Re: printf() & fork() ......
- Message-ID: <alchemy.722398030@cs1.bradley.edu>
- Sender: news@bradley.bradley.edu
- Organization: salt of the earth in open wounds.
- References: <1992Nov19.133035.172@ccsun7.csie.nctu.edu.tw>
- Date: 22 Nov 92 02:07:10 GMT
- Lines: 34
-
- In <1992Nov19.133035.172@ccsun7.csie.nctu.edu.tw> mchuang@csie.nctu.edu.tw (Ming-Chuan Huang) writes:
-
- % #include <stdio.h>
-
- % program 1:
-
- % void main()
- % {
- % printf("Hello ");
- % if (fork() == 0)
- % printf("world\n");
- % }
-
- % result:
- % Hello Hello world
-
- Under turbo cshell, I get the output:
- Hello world
- Hello Exit 1
-
- leading me to guess that the problem is that
- your output buffer isn't getting flushed the
- way you might expect it to be. You can fix
- that like so:
-
- #include <stdio.h>
-
- void main()
- {
- printf("Hello ");
- fflush(stdout);
- if (fork() == 0)
- printf("world\n");
- }
-