runtime: yield after raising signal that should kill process
runtime: yield after raising signal that should kill process

Issue #15613 points out that the darwin builders have been getting
regular failures in which a process that should exit with a SIGPIPE
signal is instead exiting with exit status 2. The code calls
runtime.raise. On most systems runtime.raise is the equivalent of
pthread_kill(gettid(), sig); that is, it kills the thread with the
signal, which should ensure that the program does not keep going. On
darwin, however, runtime.raise is actually kill(getpid(), sig); that is,
it sends a signal to the entire process. If the process decides to
deliver the signal to a different thread, then it is possible that in
some cases the thread that calls raise is able to execute the next
system call before the signal is actually delivered. That would cause
the observed error.

I have not been able to recreate the problem myself, so I don't know
whether this actually fixes it. But, optimistically:

Fixed #15613.

Change-Id: I60c0a9912aae2f46143ca1388fd85e9c3fa9df1f
Reviewed-on: https://go-review.googlesource.com/23152
Run-TryBot: Ian Lance Taylor <87e9c6d529889242b7e184afb632328636553ab4@golang.org>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Brad Fitzpatrick <ae9783c0b0efc69cd85ab025ddd17aa44cdc4aa5@golang.org>

cloudflare/go,codestation/go,suncycheng/go,theif519/go,momchil-velikov/go,4ad/go,linux-on-ibm-z/go,polyverse-security/go,4ad/go,nawawi/go,josharian/go,Cofyc/go,akutz/go,josharian/go,vsekhar/elastic-go,akutz/go,ganboing/go-esx,CAFxX/go,polyverse-security/go,nawawi/go,theif519/go,josharian/go,derekmarcotte/go,ImJasonH/go,4ad/go,momchil-velikov/go,theif519/go,vsekhar/elastic-go,theif519/go,ganboing/go-esx,polyverse-security/go,4ad/go,codestation/go,derekmarcotte/go,vsekhar/elastic-go,polyverse-security/go,suncycheng/go,polyverse-security/go,4ad/go,polyverse-security/go,momchil-velikov/go,ImJasonH/go,akutz/go,codestation/go,josharian/go,derekmarcotte/go,linux-on-ibm-z/go,CAFxX/go,codestation/go,golang/go,derekmarcotte/go,golang/go,momchil-velikov/go,akutz/go,Cofyc/go,ImJasonH/go,ganboing/go-esx,Cofyc/go,goodlang/good,Cofyc/go,derekmarcotte/go,Cofyc/go,suncycheng/go,CAFxX/go,golang/go,Cofyc/go,derekmarcotte/go,4ad/go,goodlang/good,josharian/go,cloudflare/go,akutz/go,ganboing/go-esx,CAFxX/go,akutz/go,vsekhar/elastic-go,linux-on-ibm-z/go,codestation/go,goodlang/good,theif519/go,ImJasonH/go,goodlang/good,derekmarcotte/go,cloudflare/go,CAFxX/go,akutz/go,goodlang/good,josharian/go,polyverse-security/go,nawawi/go,suncycheng/go,codestation/go,ganboing/go-esx,golang/go,nawawi/go,golang/go,ImJasonH/go,suncycheng/go,ImJasonH/go,vsekhar/elastic-go,ImJasonH/go,suncycheng/go,suncycheng/go,nawawi/go,nawawi/go,cloudflare/go,theif519/go,linux-on-ibm-z/go,akutz/go,cloudflare/go,momchil-velikov/go,linux-on-ibm-z/go,momchil-velikov/go,christopher-henderson/Go,ganboing/go-esx,linux-on-ibm-z/go,ganboing/go-esx,cloudflare/go,derekmarcotte/go,Cofyc/go,goodlang/good,momchil-velikov/go,theif519/go,josharian/go,nawawi/go,golang/go,codestation/go,cloudflare/go,nawawi/go,CAFxX/go,codestation/go,vsekhar/elastic-go,4ad/go,cloudflare/go,golang/go,4ad/go,CAFxX/go,ImJasonH/go,polyverse-security/go,linux-on-ibm-z/go,suncycheng/go,CAFxX/go,golang/go,vsekhar/elastic-go,theif519/go,momchil-velikov/go,Cofyc/go,linux-on-ibm-z/go,josharian/go,vsekhar/elastic-go,ganboing/go-esx,goodlang/good,goodlang/good