Plan 9 from Bell Labs’s /usr/web/sources/patch/exit-wrong-parent/readme

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.

If a process is started with RFNOWAIT, up->parent points to the parent's
Proc but up->parentpid is set to 0 (not the parent's actual pid).  If the
parent exits before the child, its pid becomes 0, and when the child exits
later, this code 

		p = up->parent;
		 * Check that parent is still alive.
		if(p->pid == up->parentpid && p->state != Broken) {

incorrectly treats the parent as still alive (because up->parent->pid and
up->parentpid are both zero).  So the exiting child's wait record is
passed to the dead parent ... or worse, if another fork occurs soon which
reuses the parent's Proc, we have a race which can pass the child's
wait record to some random new process (and decrement its p->nchild field).
This results in a "no living children" error if the new process tries
to wait for its real children.

The correction is to avoid the above check when up->parentpid == 0.

Note: this patch incorporates the changes from earlier patch proc-smp-fixes,
and therefore supersedes it.  It may be necessary to revert proc-smp-fixes
before applying this patch.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to