Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!mips!dimacs.rutgers.edu!aramis.rutgers.edu!paul.rutgers.edu!remus.rutgers.edu!romulus.rutgers.edu!mef From: mef@romulus.rutgers.edu (Marc Fiuczynski) Newsgroups: comp.lang.c Subject: erroneous "hello" from forked "hello world" process! Keywords: fork(), wait(), Hello World Message-ID: Date: 1 Oct 90 01:09:47 GMT Organization: Rutgers Univ., New Brunswick, N.J. Lines: 45 For my Operating System Design class we had to write some trivial programs using the fork() and wait() commands. The teaching assistant came across an interesting problem. After compiling the following: #include main () { int pid = 1; printf("Hello\n"); pid=fork(); if(pid==0){ printf("World\n"); } } We should get the output: Hello World however, when redirecting the output of a.out to a file and then doing a cat on the file we would get either: a.out > filename cat filename Hello Hello World or Hello World Hello does anyone know what is going on? Is there a problem because there are two processes output being redirected to the filename or what? Any help with this would be appreciated. -- Marc Fiuczynski mef@remus.rutgers.edu