github.com/searKing/golang/go@v1.2.117/os/signal/signal_unix.go (about) 1 // Copyright 2020 The searKing Author. 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 //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || nacl || netbsd || openbsd || solaris || windows 6 7 package signal 8 9 import ( 10 "os" 11 "syscall" 12 ) 13 14 const ( 15 numSig = 65 // max across all systems 16 ) 17 18 func Signum(sig os.Signal) int { 19 switch sig := sig.(type) { 20 case syscall.Signal: 21 i := int(sig) 22 if i < 0 || i >= numSig { 23 return -1 24 } 25 return i 26 default: 27 return -1 28 } 29 }