-
Akshat Kumar authored
On Plan 9, only the parent of a given process can enter its wait queue. When a Go program tries to fork-exec a child process and subsequently waits for it to finish, the goroutines doing these two tasks do not necessarily tie themselves to the same (or any single) OS thread. In the case that the fork and the wait system calls happen on different OS threads (say, due to a goroutine being rescheduled somewhere along the way), the wait() will either return an error or end up waiting for a completely different child than was intended. This change forces the fork and wait syscalls to happen in the same goroutine and ties that goroutine to its OS thread until the child exits. The PID of the child is recorded upon fork and exit, and de-queued once the child's wait message has been read. The Wait API, then, is translated into a synthetic implementation that simply waits for the requested PID to show up in the queue and then reads the associated stats. R=rsc, rminnich, npe, mirtchovski, ality CC=golang-dev https://golang.org/cl/6545051
b6284700