fork() is returning > 0 ???
Michael J. Eager
eager at ringworld.Eng.Sun.COM
Thu Nov 15 20:12:14 AEST 1990
In article <2691 at ux.acs.umn.edu> eric at 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
More information about the Comp.lang.c
mailing list