• Akshat Kumar's avatar
    syscall, os: fix a fork-exec/wait race in Plan 9. · b6284700
    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
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
include Loading commit data...
lib Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.hgignore Loading commit data...
.hgtags Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...