diff options
author | crunchy <crunchy> | 2002-09-14 09:55:31 +0000 |
---|---|---|
committer | crunchy <crunchy> | 2002-09-14 09:55:31 +0000 |
commit | b994b5499a4fd50675bc3c772a0c19fa2d4290ac (patch) | |
tree | 86cd72a1c8f4d95cd38899d114917facbae0ce0d /mpiosh | |
parent | 628031051a17756e48b6726ddd477d2fa5692dc2 (diff) | |
download | mpiosh-b994b5499a4fd50675bc3c772a0c19fa2d4290ac.tar.gz mpiosh-b994b5499a4fd50675bc3c772a0c19fa2d4290ac.tar.bz2 mpiosh-b994b5499a4fd50675bc3c772a0c19fa2d4290ac.zip |
better handling for SIGINT
Diffstat (limited to 'mpiosh')
-rw-r--r-- | mpiosh/mpiosh.c | 29 | ||||
-rw-r--r-- | mpiosh/mpiosh.h | 3 |
2 files changed, 20 insertions, 12 deletions
diff --git a/mpiosh/mpiosh.c b/mpiosh/mpiosh.c index aca7e19..7f8c359 100644 --- a/mpiosh/mpiosh.c +++ b/mpiosh/mpiosh.c @@ -2,7 +2,7 @@ /* * - * $Id: mpiosh.c,v 1.5 2002/09/14 07:23:59 crunchy Exp $ + * $Id: mpiosh.c,v 1.6 2002/09/14 09:55:31 crunchy Exp $ * * Author: Andreas Büsching <crunchy@tzi.de> * @@ -132,7 +132,10 @@ void mpiosh_readline_init(void) { rl_readline_name = "mpio"; + rl_catch_signals = 0; + rl_filename_quote_characters = " "; rl_attempted_completion_function = mpiosh_readline_completion; + rl_event_hook = mpiosh_readline_cancel; } char * @@ -166,9 +169,6 @@ mpiosh_readline_completion(const char *text, int start, int end) if (start == 0) matches = rl_completion_matches(text, mpiosh_readline_comp_cmd); - else { - - } return matches; } @@ -333,10 +333,17 @@ mpiosh_command_free_args(char **args) free(args); } +int +mpiosh_readline_cancel(void) +{ + if (mpiosh_cancel) rl_done = 1; + + return 0; +} + void mpiosh_signal_handler(int signal) { - debug("user abort!\n"); mpiosh_cancel = 1; } @@ -362,13 +369,11 @@ main(int argc, char *argv[]) { sigaction(SIGINT, &sigc, NULL); -/* signal(SIGINT, SIG_IGN); */ - /* init readline and history */ + mpiosh_readline_init(); using_history(); debug_init(); - mpiosh_readline_init(); mpiosh_init(); mpiosh.dev = mpio_init(); @@ -389,7 +394,11 @@ main(int argc, char *argv[]) { } while ((line = readline(mpiosh.prompt))) { - if (*line == '\0') continue; + if ((*line == '\0') || mpiosh_cancel) { + rl_clear_pending_input (); + mpiosh_cancel = 0; + continue; + } cmds = mpiosh_command_split(line); @@ -428,5 +437,3 @@ main(int argc, char *argv[]) { return 0; } - - diff --git a/mpiosh/mpiosh.h b/mpiosh/mpiosh.h index c6e8755..944e73d 100644 --- a/mpiosh/mpiosh.h +++ b/mpiosh/mpiosh.h @@ -2,7 +2,7 @@ * * Author: Andreas Büsching <crunchy@tzi.de> * - * $Id: mpiosh.h,v 1.3 2002/09/13 15:20:25 crunchy Exp $ + * $Id: mpiosh.h,v 1.4 2002/09/14 09:55:31 crunchy Exp $ * * Copyright (C) 2002 Andreas Büsching <crunchy@tzi.de> * @@ -46,6 +46,7 @@ void mpiosh_signal_handler(int signal); void mpiosh_readline_init(void); char **mpiosh_readline_completion(const char *text, int start, int end); char *mpiosh_readline_comp_cmd(const char *text, int state); +int mpiosh_readline_cancel(void); /* helper functions */ void mpiosh_init(void); |