1 //go:build tinygo
2 3 // Package sigtrap nudges TinyGo's cooperative scheduler to process pending
4 // signals.
5 //
6 // On Linux, TinyGo's os/signal handler records a signal but the scheduler only
7 // drains that record when it enters an idle wait. A relay almost always has a
8 // socket parked in netpoll, so the scheduler never reaches that path and
9 // SIGTERM would sit unprocessed until the next unrelated timer wakeup -- or
10 // never. Calling the runtime's checkSignals from a periodic goroutine closes
11 // that gap.
12 package sigtrap
13 14 import _ "unsafe"
15 16 //go:linkname checkSignals runtime.checkSignals
17 func checkSignals() bool
18 19 // Trap asks the runtime to hand any pending signal to os/signal.
20 func Trap() { checkSignals() }
21