Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestBuild(t *testing.T) {
"print.go",
"reflect.go",
"signal.go",
"signalnotify.go",
"slice.go",
"sort.go",
"stdlib.go",
Expand Down Expand Up @@ -440,7 +441,14 @@ func runPlatTests(options compileopts.Options, tests []string, t *testing.T) {
continue
}
}
if isWebAssembly || isBaremetal || options.GOOS == "windows" {
if options.GOOS == "windows" {
switch name {
case "signal.go", "signalnotify.go":
// os/signal does not link on Windows.
continue
}
}
if isWebAssembly || isBaremetal {
switch name {
case "signal.go":
// Signals only work on POSIX-like systems.
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/signalstub.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ func signal_ignore(uint32) {}
func signal_waitUntilIdle() {}

//go:linkname signal_recv os/signal.signal_recv
func signal_recv() uint32 { return ^uint32(0) }
func signal_recv() uint32 {
// Block to prevent os/signal.loop from running continuously.
// See https://go.dev/src/os/signal/signal_unix.go.
deadlock()
return 0
}
14 changes: 14 additions & 0 deletions testdata/signalnotify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"os"
"os/signal"
"time"
)

func main() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
time.Sleep(10 * time.Millisecond)
println("done")
}
1 change: 1 addition & 0 deletions testdata/signalnotify.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
done
Loading