Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!ringworld.Eng.Sun.COM!eager From: eager@ringworld.Eng.Sun.COM (Michael J. Eager) Newsgroups: comp.lang.c Subject: Re: fork() is returning > 0 ??? Message-ID: <2846@exodus.Eng.Sun.COM> Date: 15 Nov 90 09:12:14 GMT References: <2691@ux.acs.umn.edu> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 28 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? When it works fine in other situations in the same > > switch (fork ()) { > case -1: > Msg (errno, "fork"); > /*NOTREACHED*/ > case 0: > break; > default: > Attacher (); > /*NOTREACHED*/ > } RTFM :-) RETURN VALUES On success, fork() returns 0 to the child process and returns the process ID of the child process to the parent process. On failure, fork() returns -1 to the parent pro- cess, sets errno to indicate the error, and no child process is created. It looks like fork is returning the PID of the child process. Isn't this what you wanted? -- Mike Eager