Source file src/pkg/os/signal/signal_unix.go
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build darwin freebsd linux netbsd openbsd windows
6
7 package signal
8
9 import (
10 "os"
11 "syscall"
12 )
13
14 // In assembly.
15 func signal_enable(uint32)
16 func signal_recv() uint32
17
18 func loop() {
19 for {
20 process(syscall.Signal(signal_recv()))
21 }
22 }
23
24 func init() {
25 signal_enable(0) // first call - initialize
26 go loop()
27 }
28
29 func enableSignal(sig os.Signal) {
30 switch sig := sig.(type) {
31 case nil:
32 signal_enable(^uint32(0))
33 case syscall.Signal:
34 signal_enable(uint32(sig))
35 default:
36 // Can ignore: this signal (whatever it is) will never come in.
37 }
38 }