Re: [PATCH] fix do_fork() return value

Pavel Machek (pavel@ucw.cz)
Sun, 25 May 2003 19:31:20 +0200


Hi!

> # Noticed by Julie DeWandel <jdewand@redhat.com>.
> #
> # do_fork() needs to return the pid (or error), not the pointer to the
> # resulting process structure. The process structure may not even be
> # valid any more, since do_fork() has already woken the process up (and as
> # a result it might already have done its thing and gone away).
> #
> # Besides, doing it this way cleans up the users, which all really just
> # wanted the pid or error number _anyway_.
>
> Just FYI: the change was done in the first place to allow spawning a
> new init thread as CPUs come up. But now we have copy_process it can
> be done neatly (it should also be done out of keventd so we get a
> clean thread, but that's another story).
>
> Note that this version also has a (theoretical) race, except hidden
> by the time to wrap PIDs ie. "never happens".

We have more such wrappers. IIRC, it is possible to go into
/proc/PID/something, and just stay there, kill the process, and wait
for PIDs to wrap around, fun stuff happens...
Pavel

-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/