# HG changeset patch # User Tero Marttila # Date 1242914248 -10800 # Node ID ddc79529a1e0d5cde2b69d4cdd7d1eb6741495cd # Parent b460d958a685cd505ebfcb4ad5dbfb00681eadf3 add a console_callbacks::on_interrupt callback triggered by SIGINT while waiting diff -r b460d958a685 -r ddc79529a1e0 src/console.c --- a/src/console.c Thu May 21 16:57:00 2009 +0300 +++ b/src/console.c Thu May 21 16:57:28 2009 +0300 @@ -115,20 +115,26 @@ break; } } - static void on_sigint (int sig) { struct console *console = &_console; (void) sig; - // interrupt the input line - // XXX: is this the right function to call? - rl_free_line_state(); + if (console->waiting) { + // notify user + if (console->callbacks->on_interrupt) + console->callbacks->on_interrupt(console->cb_arg); - // redisplay on new line - rl_crlf(); - rl_callback_handler_install(console->config.prompt, console_line); + } else { + // interrupt the input line + // XXX: is this the right function to call? + rl_free_line_state(); + + // redisplay on new line + rl_crlf(); + rl_callback_handler_install(console->config.prompt, console_line); + } } err_t console_init (struct console **console_ptr, struct event_base *ev_base, const struct console_config *config, diff -r b460d958a685 -r ddc79529a1e0 src/console.h --- a/src/console.h Thu May 21 16:57:00 2009 +0300 +++ b/src/console.h Thu May 21 16:57:28 2009 +0300 @@ -54,6 +54,12 @@ * Note that for interactive consoles, EOF isn't actually EOF - there might be multiple EOFs... */ void (*on_eof) (void *arg); + + /** + * An input interrupt (SIGINT) was recieved while in the wait state. This can be used to abort execution and + * call console_continue quickly. + */ + void (*on_interrupt) (void *arg); }; /**