Source file
src/os/signal/signal_plan9.go
1
2
3
4
5 package signal
6
7 import (
8 "os"
9 "syscall"
10 )
11
12 var sigtab = make(map[os.Signal]int)
13
14
15 func signal_disable(uint32)
16 func signal_enable(uint32)
17 func signal_ignore(uint32)
18 func signal_ignored(uint32) bool
19 func signal_recv() string
20
21 func init() {
22 watchSignalLoop = loop
23 }
24
25 func loop() {
26 for {
27 process(syscall.Note(signal_recv()))
28 }
29 }
30
31 const numSig = 256
32
33 func signum(sig os.Signal) int {
34 switch sig := sig.(type) {
35 case syscall.Note:
36 n, ok := sigtab[sig]
37 if !ok {
38 n = len(sigtab) + 1
39 if n > numSig {
40 return -1
41 }
42 sigtab[sig] = n
43 }
44 return n
45 default:
46 return -1
47 }
48 }
49
50 func enableSignal(sig int) {
51 signal_enable(uint32(sig))
52 }
53
54 func disableSignal(sig int) {
55 signal_disable(uint32(sig))
56 }
57
58 func ignoreSignal(sig int) {
59 signal_ignore(uint32(sig))
60 }
61
62 func signalIgnored(sig int) bool {
63 return signal_ignored(uint32(sig))
64 }
65
View as plain text