Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Created April 25, 2020 14:03
Show Gist options
  • Select an option

  • Save Code-Hex/3f4366054a3c13e0e892c328715e2c89 to your computer and use it in GitHub Desktop.

Select an option

Save Code-Hex/3f4366054a3c13e0e892c328715e2c89 to your computer and use it in GitHub Desktop.
shell 上でどんな signal を受け取ったか見る
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
sig := make(chan os.Signal, 1)
signal.Notify(
sig,
syscall.SIGTERM,
syscall.SIGHUP,
syscall.SIGSTOP,
syscall.SIGCONT,
)
result := <-sig
fmt.Println(result)
}
@Code-Hex
Copy link
Copy Markdown
Author

$ go build signal.go
$ ./signal >> log

$ # ^z (suspend)
$ # ^d
$ # ^d <= ここで shell がどんなシグナルを送ってるか見る

別セッション

$ cat log
  • bash => SIGTERM
  • zsh => SIGHUP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment