github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/autofile/autofile_unix.go (about) 1 //go:build !js && !wasm 2 // +build !js,!wasm 3 4 package autofile 5 6 import ( 7 "os" 8 "os/signal" 9 "syscall" 10 ) 11 12 func (af *AutoFile) setupCloseHandler() error { 13 // Close file on SIGHUP. 14 af.hupc = make(chan os.Signal, 1) 15 signal.Notify(af.hupc, syscall.SIGHUP) 16 go func() { 17 for range af.hupc { 18 af.closeFile() 19 } 20 }() 21 return nil 22 }