From: Ian Lance Taylor Date: Wed, 16 Nov 2016 05:15:40 +0000 (-0800) Subject: runtime: sleep a bit to let a bad signal be delivered X-Git-Tag: go1.8beta1~77 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=75055de84ab7ad0f36b4c93e5c851ea55b297c95;p=gostls13.git runtime: sleep a bit to let a bad signal be delivered When we raise a signal that was delivered to C code, it's possible that the kernel will not deliver it immediately. This is especially possible on Darwin where we use send the signal to the entire process rather than just the current thread. Sleep for a millisecond after sending the signal to give it a chance to be delivered before we restore the Go signal handler. In most real cases the program is going to crash at this point, so sleeping is kind of irrelevant anyhow. Fixes #14809. Change-Id: Ib2c0d2c4e240977fb4535dc1dd2bdc50d430eb85 Reviewed-on: https://go-review.googlesource.com/33300 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 8b932341a9..78381e58d7 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -354,6 +354,11 @@ func raisebadsignal(sig uint32, c *sigctxt) { raise(sig) + // Give the signal a chance to be delivered. + // In almost all real cases the program is about to crash, + // so sleeping here is not a waste of time. + usleep(1000) + // If the signal didn't cause the program to exit, restore the // Go signal handler and carry on. //