func handleSignals() { signals := make(chan os.Signal, 1) signal.Notify(signals, syscall.SIGWINCH) for s := range signals { switch s { case syscall.SIGWINCH: C.rl_resize_terminal() } } }
// https://code.google.com/p/go/issues/detail?id=4216 func init() { // Program received signal SIGSEGV, Segmentation fault. // rl_sigwinch_handler (sig=-136463680) at /tmp/buildd/readline6-6.2+dfsg/signals.c:267 // 267 RL_UNSETSTATE(RL_STATE_SIGHANDLER); C.rl_catch_sigwinch = 0 resized := make(chan os.Signal, 1) go func() { for _ = range resized { C.rl_resize_terminal() } }() signal.Notify(resized, syscall.SIGWINCH) }
func initReadLine() { C.rl_catch_sigwinch = 0 C.rl_catch_signals = 0 c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGWINCH) signal.Notify(c, os.Interrupt) go func() { for sig := range c { switch sig { case syscall.SIGWINCH: C.rl_resize_terminal() case os.Interrupt: C.rl_cleanup_after_signal() default: } } }() }
func handleSignals() { C.rl_catch_signals = 0 C.rl_catch_sigwinch = 0 signals := make(chan os.Signal, 2) signal.Notify(signals, syscall.SIGINT, syscall.SIGWINCH) for s := range signals { switch s { case syscall.SIGWINCH: C.rl_resize_terminal() case syscall.SIGINT: if CatchSigint { Cleanup() os.Exit(1) } } } }
func Resize() { C.rl_resize_terminal() }
func handleSignals() { signals := make(chan os.Signal) signal.Notify(signals, syscall.SIGWINCH) <-signals C.rl_resize_terminal() }