dongpo4197
dongpo4197
2014-04-28 19:26

在Cygwin上捕捉Ctrl + c

  • cygwin
  • signals
  • ctrl

The following golang code catches CTRL+C when run from a DOS prompt, but when I run it from Cygwin it doesn't catch anything when CTRL+C is pressed.

What does Cygwin do when CTRL+C is pressed? My OS is Win7 64 bit running 32 bit Cygwin.

    func main() {
        c := make(chan os.Signal, 1)
        signal.Notify(c, os.Interrupt)
        go func(){
        for sig := range c {
            fmt.Println(sig.String())
        }
        }()

        time.Sleep(5000 * time.Millisecond) 
        fmt.Println("Done")
    }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐