Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGINT from Ctrl-C ignored #50

Closed
jefflund opened this issue Oct 27, 2014 · 2 comments
Closed

SIGINT from Ctrl-C ignored #50

jefflund opened this issue Oct 27, 2014 · 2 comments

Comments

@jefflund
Copy link

Suppose I was silly and ran the following program:

package main

import (
        "github.com/nsf/termbox-go"
)

func main() {
        termbox.Init()
        defer termbox.Close()

        for {
                e := termbox.PollEvent()
                termbox.SetCell(0, 0, e.Ch, termbox.ColorDefault, termbox.ColorDefault)
                termbox.Flush()
        }
}

While it does the intended thing of displaying the last key press, I accidentally wrote an infinite loop. Normally, I would just press ctrl-c to send a SIGINT, and the program would use the default signal handler and just quietly terminate. However, with termbox, instead the ctrl-c is not seen as a SIGINT. Instead, the ctrl-c will show up as an event from PollEvent. Obviously I'm being cheeky with this example, but in general, is there a way to tell termbox to respect the default signal handlers for things like SIGINT from ctrl-c or SIGTSTP from ctrl-z?

@nsf
Copy link
Owner

nsf commented Oct 27, 2014

It doesn't ignore SIGINT, it disables binding of Ctrl-C to SIGINT. You can still kill the app with a "kill" command or any other way you can send a SIGINT signal to it. I'm afraid it's impossible to get Ctrl-C binding back as termbox uses raw terminal input mode.

Applications like emacs could use this feature, I mean C-c is an ordinary key combo in emacs. So even if it's possible to enable C-c sending SIGINT alone, I wouldn't do it.

@jefflund
Copy link
Author

Thanks for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants