• Richard Miller's avatar
    runtime: avoid fork/exit race in plan9 · 967b9940
    Richard Miller authored
    There's a race between runtime.goexitsall killing all OS processes
    of a go program in order to exit, and runtime.newosproc forking a
    new one.  If the new process has been created but not yet stored
    its pid in m.procid, it will not be killed by goexitsall and
    deadlock results.
    
    This CL prevents the race by making the newly forked process
    check whether the program is exiting.  It also prevents a
    potential "shoot-out" if multiple goroutines call Exit at
    the same time, which could possibly lead to two processes
    killing each other and leaving the rest deadlocked.
    
    Change-Id: I3170b4a62d2461f6b029b3d6aad70373714ed53e
    Reviewed-on: https://go-review.googlesource.com/21135
    Run-TryBot: David du Colombier <0intro@gmail.com>
    Reviewed-by: 's avatarMarvin Stenger <marvin.stenger94@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarDavid du Colombier <0intro@gmail.com>
    967b9940
os1_plan9.go 5.31 KB