Closed cjpatton closed 9 years ago
You can indeed access the signal number. os.Signal is the generic interface type used for the signal mechanism. We are always running on linux, where the concrete type will be syscall.Signal, which converts directly to int. So:
signum := int(sig.(syscall.Signal))
Or if you are paranoid:
signum := syscall.SIGINT; // some reasonable default? if s, ok := sig.(syscall.Signal); ok { signum = int(s) }
Thanks, John, that's immensely helpful.
See go/apps/mixnet/mixnet_router/mixnet_router.go:90 for related TODO. To handle signals in Go, one creates a chan os.Signal and run a go routine that waits on that channel. So we free up any resources that need to be freed and call os.Exit(), which accepts as input a byte conveying the exit status to the OS. We would like this status to reflect the type of signal that was captured, but the os.Signal interface provides no means for getting at the signal number. This is less a CloudProxy issue and more an issue of the os.Signal interface.