Source: --- 8< --- package main
import ( "os" "os/signal" ) func main() { sigs := make(chan os.Signal) signal.Notify(sigs, os.Interrupt) if f := os.NewFile(3, ""); f != nil { f.Close() } <-sigs } --- >8 --- Stack: --- 8< --- fatal error: signal_recv: inconsistent state goroutine 4 [running]: runtime.throw(0x109865b, 0x1f) /Users/saj/.homebrew/Cellar/go/1.13.4/libexec/src/runtime/panic.go:774 +0x72 fp=0xc0000337a0 sp=0xc000033770 pc=0x1028922 os/signal.signal_recv(0x0) /Users/saj/.homebrew/Cellar/go/1.13.4/libexec/src/runtime/sigqueue.go:140 +0x104 fp=0xc0000337c0 sp=0xc0000337a0 pc=0x103d1e4 os/signal.loop() /Users/saj/.homebrew/Cellar/go/1.13.4/libexec/src/os/signal/signal_unix.go:23 +0x22 fp=0xc0000337e0 sp=0xc0000337c0 pc=0x106bac2 runtime.goexit() /Users/saj/.homebrew/Cellar/go/1.13.4/libexec/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc0000337e8 sp=0xc0000337e0 pc=0x10524d1 created by os/signal.init.0 /Users/saj/.homebrew/Cellar/go/1.13.4/libexec/src/os/signal/signal_unix.go:29 +0x41 goroutine 1 [chan receive]: main.main() /private/var/tmp/shstash-735678213/main.go:16 +0xbf --- >8 --- The program was executed _without_ an inherited file on fd 3, i.e.: % cat <&3 zsh: 3: bad file descriptor I assumed the runtime had opened its own file, and by blindly closing fd 3 I was interfering with it somehow, but I could not see any obvious file operations in the sources listed in the stack. % go version go version go1.13.4 darwin/amd64 % sw_vers ProductName: Mac OS X ProductVersion: 10.14.6 BuildVersion: 18G103 This program does not crash when compiled and executed in the same way on Linux (go version go1.13.4 linux/amd64). Cheers. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAFC7SCo_onbp9oRCSotybKYXVxjz5tW3egDc6H3VRwQkByVFpA%40mail.gmail.com.