diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-03-31 12:41:52 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-03-31 12:41:52 +0000 |
| commit | 422cd7c81c25bdf5155d09aecfe5bd9d5c28a1f7 (patch) | |
| tree | 5d8ba93759402e74608284619bdeb76683adfdcf | |
| parent | abedaac8423d72325ae05602bf1bdcde28ecd7fa (diff) | |
| download | busybox-w32-422cd7c81c25bdf5155d09aecfe5bd9d5c28a1f7.tar.gz busybox-w32-422cd7c81c25bdf5155d09aecfe5bd9d5c28a1f7.tar.bz2 busybox-w32-422cd7c81c25bdf5155d09aecfe5bd9d5c28a1f7.zip | |
hush: make ^C work again, ^Z probably isn't working
function old new delta
file_get 219 254 +35
check_and_run_traps 122 133 +11
run_list 2001 2010 +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 55/0) Total: 55 bytes
| -rw-r--r-- | shell/hush.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/shell/hush.c b/shell/hush.c index 01690d9bc..21fa95429 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -462,6 +462,7 @@ struct globals { | |||
| 462 | struct pipe *toplevel_list; | 462 | struct pipe *toplevel_list; |
| 463 | //// smallint ctrl_z_flag; | 463 | //// smallint ctrl_z_flag; |
| 464 | #endif | 464 | #endif |
| 465 | smallint flag_SIGINT; | ||
| 465 | #if ENABLE_HUSH_LOOPS | 466 | #if ENABLE_HUSH_LOOPS |
| 466 | smallint flag_break_continue; | 467 | smallint flag_break_continue; |
| 467 | #endif | 468 | #endif |
| @@ -881,15 +882,16 @@ static void check_and_run_traps(void) | |||
| 881 | continue; | 882 | continue; |
| 882 | } | 883 | } |
| 883 | /* not a trap: special action */ | 884 | /* not a trap: special action */ |
| 884 | #if 0 //TODO | ||
| 885 | switch (sig) { | 885 | switch (sig) { |
| 886 | case SIGHUP: ... | 886 | case SIGINT: |
| 887 | break; | 887 | G.flag_SIGINT = 1; |
| 888 | case SIGINT: ... | ||
| 889 | break; | 888 | break; |
| 889 | //TODO | ||
| 890 | // case SIGHUP: ... | ||
| 891 | // break; | ||
| 890 | default: /* SIGTERM, SIGQUIT, SIGTTIN, SIGTTOU, SIGTSTP */ | 892 | default: /* SIGTERM, SIGQUIT, SIGTTIN, SIGTTOU, SIGTSTP */ |
| 893 | break; | ||
| 891 | } | 894 | } |
| 892 | #endif | ||
| 893 | } | 895 | } |
| 894 | } | 896 | } |
| 895 | 897 | ||
| @@ -1195,18 +1197,27 @@ static void get_user_input(struct in_str *i) | |||
| 1195 | /* Enable command line editing only while a command line | 1197 | /* Enable command line editing only while a command line |
| 1196 | * is actually being read */ | 1198 | * is actually being read */ |
| 1197 | do { | 1199 | do { |
| 1200 | G.flag_SIGINT = 0; | ||
| 1201 | /* buglet: SIGINT will not make new prompt to appear _at once_, | ||
| 1202 | * only after <Enter>. (^C will work) */ | ||
| 1198 | r = read_line_input(prompt_str, G.user_input_buf, BUFSIZ-1, G.line_input_state); | 1203 | r = read_line_input(prompt_str, G.user_input_buf, BUFSIZ-1, G.line_input_state); |
| 1199 | } while (r == 0); /* repeat if Ctrl-C */ | 1204 | /* catch *SIGINT* etc (^C is handled by read_line_input) */ |
| 1205 | check_and_run_traps(); | ||
| 1206 | } while (r == 0 || G.flag_SIGINT); /* repeat if ^C or SIGINT */ | ||
| 1200 | i->eof_flag = (r < 0); | 1207 | i->eof_flag = (r < 0); |
| 1201 | if (i->eof_flag) { /* EOF/error detected */ | 1208 | if (i->eof_flag) { /* EOF/error detected */ |
| 1202 | G.user_input_buf[0] = EOF; /* yes, it will be truncated, it's ok */ | 1209 | G.user_input_buf[0] = EOF; /* yes, it will be truncated, it's ok */ |
| 1203 | G.user_input_buf[1] = '\0'; | 1210 | G.user_input_buf[1] = '\0'; |
| 1204 | } | 1211 | } |
| 1205 | #else | 1212 | #else |
| 1206 | fputs(prompt_str, stdout); | 1213 | do { |
| 1207 | fflush(stdout); | 1214 | G.flag_SIGINT = 0; |
| 1208 | G.user_input_buf[0] = r = fgetc(i->file); | 1215 | fputs(prompt_str, stdout); |
| 1209 | /*G.user_input_buf[1] = '\0'; - already is and never changed */ | 1216 | fflush(stdout); |
| 1217 | G.user_input_buf[0] = r = fgetc(i->file); | ||
| 1218 | /*G.user_input_buf[1] = '\0'; - already is and never changed */ | ||
| 1219 | //do we need check_and_run_traps()? (maybe only if stdin) | ||
| 1220 | } while (G.flag_SIGINT); | ||
| 1210 | i->eof_flag = (r == EOF); | 1221 | i->eof_flag = (r == EOF); |
| 1211 | #endif | 1222 | #endif |
| 1212 | i->p = G.user_input_buf; | 1223 | i->p = G.user_input_buf; |
| @@ -2845,6 +2856,9 @@ static int run_list(struct pipe *pi) | |||
| 2845 | 2856 | ||
| 2846 | /* Go through list of pipes, (maybe) executing them. */ | 2857 | /* Go through list of pipes, (maybe) executing them. */ |
| 2847 | for (; pi; pi = USE_HUSH_LOOPS(rword == RES_DONE ? loop_top : ) pi->next) { | 2858 | for (; pi; pi = USE_HUSH_LOOPS(rword == RES_DONE ? loop_top : ) pi->next) { |
| 2859 | if (G.flag_SIGINT) | ||
| 2860 | break; | ||
| 2861 | |||
| 2848 | IF_HAS_KEYWORDS(rword = pi->res_word;) | 2862 | IF_HAS_KEYWORDS(rword = pi->res_word;) |
| 2849 | IF_HAS_NO_KEYWORDS(rword = RES_NONE;) | 2863 | IF_HAS_NO_KEYWORDS(rword = RES_NONE;) |
| 2850 | debug_printf_exec(": rword=%d cond_code=%d skip_more=%d\n", | 2864 | debug_printf_exec(": rword=%d cond_code=%d skip_more=%d\n", |
