mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: use a pipe to wake up signal_recv on Darwin
The implementation of semaphores, and therefore notes, used on Darwin is not async-signal-safe. The runtime has one case where a note needs to be woken up from a signal handler: the call to notewakeup in sigsend. That notewakeup call is only called on a single note, and it doesn't need the full functionality of notes: nothing ever does a timed wait on it. So change that one note to use a different implementation on Darwin, based on a pipe. This lets the wakeup code use the write call, which is async-signal-safe. Fixes #31264 Change-Id: If705072d7a961dd908ea9d639c8d12b222c64806 Reviewed-on: https://go-review.googlesource.com/c/go/+/184169 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
623d653db7
commit
c485e8b559
13 changed files with 159 additions and 0 deletions
25
src/runtime/sigqueue_note.go
Normal file
25
src/runtime/sigqueue_note.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// The current implementation of notes on Darwin is not async-signal-safe,
|
||||
// so on Darwin the sigqueue code uses different functions to wake up the
|
||||
// signal_recv thread. This file holds the non-Darwin implementations of
|
||||
// those functions. These functions will never be called.
|
||||
|
||||
// +build !darwin
|
||||
// +build !plan9
|
||||
|
||||
package runtime
|
||||
|
||||
func sigNoteSetup(*note) {
|
||||
throw("sigNoteSetup")
|
||||
}
|
||||
|
||||
func sigNoteSleep(*note) {
|
||||
throw("sigNoteSleep")
|
||||
}
|
||||
|
||||
func sigNoteWakeup(*note) {
|
||||
throw("sigNoteWakeup")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue