Hi Blake,

I tried, but it did not work.

The deeper I go into readline the more weird it gets.

If I do nothing then I get the first ^C delivered as signal but not subsequent ones. I would have preferred if two ^Cs (i.e. INTERRUPT rather than ATTENTION) would
stop printouts, but readline delivers only one.

I also tried binding to ^C; interestingly I can bind to any other key except ^C. The
bind to ^C succeeds (returns no error) but the function bound to it is not
called. For other keys this works.

/// Jürgen


On 07/21/2014 08:12 PM, Blake McBride wrote:
Does this help?

This may be related to the cooked/uncooked/rare <http://en.wikipedia.org/wiki/POSIX_terminal_interface#Early_Unices%3a_Seventh_Edition_Unix> terminal modes; |^C| does not always send a signal. It seems likely that readline uncooks the terminal, and thus any signals caused by keyboard input must be due to logic within readline itself; it seems plausible that it might only trigger a SIGINT on two sequential |^C|s (especially since for many programs that utilise readline such as shells and REPLs, the program exiting on a single |^C| would be very annoying!).

You might be able to change this behaviour by using the readline API to rebind |^C| to some of your own code that triggers a SIGINT. I haven't used readline from Haskell, just from C, so I'm not sure exactly how you'd go about this, but the binding <http://hackage.haskell.org/packages/archive/readline/latest/doc/html/System-Console-Readline.html> seems rich enough to achieve it.



/Blake McBride/
/
/
www.arahant.com <http://www.arahant.com/>
Cell:    615-394-6760
Office:  615-376-5500
Fax:     615-377-6006






Reply via email to