...
1
2
3
4
5 package main
6
7 import "C"
8
9 import (
10 "os"
11 "os/signal"
12 "syscall"
13 "time"
14 )
15
16
17 var sigioChan chan os.Signal
18
19
20
21
22 func CatchSIGIO() {
23 sigioChan = make(chan os.Signal, 1)
24 signal.Notify(sigioChan, syscall.SIGIO)
25 }
26
27
28
29
30 func ResetSIGIO() {
31 signal.Reset(syscall.SIGIO)
32 }
33
34
35
36
37 func SawSIGIO() C.int {
38 select {
39 case <-sigioChan:
40 return 1
41 case <-time.After(5 * time.Second):
42 return 0
43 }
44 }
45
46
47
48
49 func ProvokeSIGPIPE() {
50 r, w, err := os.Pipe()
51 if err != nil {
52 panic(err)
53 }
54 r.Close()
55 defer w.Close()
56 w.Write([]byte("some data"))
57 }
58
59 func main() {
60 }
61
View as plain text