Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!julius.cs.uiuc.edu!usc!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: fork() is returning > 0 ??? Message-ID: <4232@goanna.cs.rmit.oz.au> Date: 10 Nov 90 09:32:43 GMT References: <2691@ux.acs.umn.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 20 In article <2691@ux.acs.umn.edu>, eric@ux.acs.umn.edu (Merlinus Ambrosius) writes: > Can you explain why in this piece of code, fork() is returning a value > other than -1 or 0? Because it ought to. RTFM. If you're talking about the UNIX fork(2) system call, it yields one of three results: -1 => something went wrong, we've still just one process and this is it 0 => forking worked, and _this_ process is the child N => forking worked, _this_ process is the parent, and the child process has process it N. If you are going to wait for the child to finish, you _need_ this number. (Look at the DIAGNOSTICS section of the fork(2) manual page.) > |Eric (the "Mentat-Philosopher") Hendrickson University of Minnesota Um, if you're a Mentat, how come you need a computer? Mentats were supposed to be the human replacements for computers after the Butlerian Jihad. -- The problem about real life is that moving one's knight to QB3 may always be replied to with a lob across the net. --Alasdair Macintyre.