github.com/akaros/go-akaros@v0.0.0-20181004170632-85005d477eab/src/os/signal/signal_akaros.go (about) 1 // Copyright 2014 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 package signal 6 7 import ( 8 "os" 9 "runtime/parlib" 10 "syscall" 11 ) 12 13 const ( 14 numSig = parlib.NSIG 15 ) 16 17 func signum(sig os.Signal) int { 18 switch sig := sig.(type) { 19 case syscall.Signal: 20 i := int(sig) 21 if i < 1 || i >= numSig { 22 return -1 23 } 24 return i 25 default: 26 return -1 27 } 28 } 29 30 func process_wrapper(sig int) { 31 process(syscall.Signal(sig)) 32 } 33 34 func enableSignal(sig int) { 35 parlib.Signal(sig, process_wrapper) 36 } 37 38 func disableSignal(sig int) { 39 parlib.Signal(sig, nil) 40 }