diff options
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c index 3919118f0..0038aa1e9 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -929,6 +929,7 @@ raise_interrupt(void) | |||
929 | raise(SIGINT); | 929 | raise(SIGINT); |
930 | #else | 930 | #else |
931 | fflush_all(); | 931 | fflush_all(); |
932 | kill(-getpid(), SIGINT); | ||
932 | _exit(SIGINT << 24); | 933 | _exit(SIGINT << 24); |
933 | #endif | 934 | #endif |
934 | } | 935 | } |
@@ -4274,7 +4275,7 @@ signal_handler(int signo) | |||
4274 | return; | 4275 | return; |
4275 | } | 4276 | } |
4276 | #if ENABLE_FEATURE_EDITING | 4277 | #if ENABLE_FEATURE_EDITING |
4277 | bb_got_signal = signo; /* for read_line_input: "we got a signal" */ | 4278 | bb_got_signal = signo; /* for read_line_input / read builtin: "we got a signal" */ |
4278 | #endif | 4279 | #endif |
4279 | gotsig[signo - 1] = 1; | 4280 | gotsig[signo - 1] = 1; |
4280 | pending_sig = signo; | 4281 | pending_sig = signo; |
@@ -15812,6 +15813,7 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
15812 | r = shell_builtin_read(¶ms); | 15813 | r = shell_builtin_read(¶ms); |
15813 | INT_ON; | 15814 | INT_ON; |
15814 | 15815 | ||
15816 | #if !ENABLE_PLATFORM_MINGW32 | ||
15815 | if ((uintptr_t)r == 1 && errno == EINTR) { | 15817 | if ((uintptr_t)r == 1 && errno == EINTR) { |
15816 | /* To get SIGCHLD: sleep 1 & read x; echo $x | 15818 | /* To get SIGCHLD: sleep 1 & read x; echo $x |
15817 | * Correct behavior is to not exit "read" | 15819 | * Correct behavior is to not exit "read" |
@@ -15820,8 +15822,15 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
15820 | goto again; | 15822 | goto again; |
15821 | } | 15823 | } |
15822 | 15824 | ||
15823 | #if ENABLE_PLATFORM_MINGW32 | 15825 | if ((uintptr_t)r == 2) /* -t SEC timeout? */ |
15826 | /* bash: "The exit status is greater than 128 if the timeout is exceeded." */ | ||
15827 | /* The actual value observed with bash 5.2.15: */ | ||
15828 | return 128 + SIGALRM; | ||
15829 | #else /* ENABLE_PLATFORM_MINGW32 */ | ||
15824 | if ((uintptr_t)r == 2) { | 15830 | if ((uintptr_t)r == 2) { |
15831 | /* Timeout, return 128 + SIGALRM */ | ||
15832 | return 142; | ||
15833 | } else if ((uintptr_t)r == 3) { | ||
15825 | /* ^C pressed, propagate event */ | 15834 | /* ^C pressed, propagate event */ |
15826 | if (trap[SIGINT]) { | 15835 | if (trap[SIGINT]) { |
15827 | write(STDOUT_FILENO, "^C", 2); | 15836 | write(STDOUT_FILENO, "^C", 2); |
@@ -15969,8 +15978,25 @@ exitshell(void) | |||
15969 | char *p; | 15978 | char *p; |
15970 | 15979 | ||
15971 | #if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT | 15980 | #if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT |
15972 | save_history(line_input_state); /* may be NULL */ | 15981 | if (line_input_state) { |
15982 | const char *hp; | ||
15983 | # if ENABLE_FEATURE_SH_HISTFILESIZE | ||
15984 | // in bash: | ||
15985 | // HISTFILESIZE controls the on-disk history file size (in lines, 0=no history): | ||
15986 | // "When this variable is assigned a value, the history file is truncated, if necessary" | ||
15987 | // but we do it only at exit, not on assignment: | ||
15988 | /* Use HISTFILESIZE to limit file size */ | ||
15989 | hp = lookupvar("HISTFILESIZE"); | ||
15990 | if (hp) | ||
15991 | line_input_state->max_history = size_from_HISTFILESIZE(hp); | ||
15992 | # endif | ||
15993 | /* HISTFILE: "If unset, the command history is not saved when a shell exits." */ | ||
15994 | hp = lookupvar("HISTFILE"); | ||
15995 | line_input_state->hist_file = hp; | ||
15996 | save_history(line_input_state); /* no-op if hist_file is NULL or "" */ | ||
15997 | } | ||
15973 | #endif | 15998 | #endif |
15999 | |||
15974 | savestatus = exitstatus; | 16000 | savestatus = exitstatus; |
15975 | TRACE(("pid %d, exitshell(%d)\n", getpid(), savestatus)); | 16001 | TRACE(("pid %d, exitshell(%d)\n", getpid(), savestatus)); |
15976 | if (setjmp(loc.loc)) | 16002 | if (setjmp(loc.loc)) |
@@ -16474,7 +16500,12 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
16474 | if (hp) | 16500 | if (hp) |
16475 | line_input_state->hist_file = xstrdup(hp); | 16501 | line_input_state->hist_file = xstrdup(hp); |
16476 | # if ENABLE_FEATURE_SH_HISTFILESIZE | 16502 | # if ENABLE_FEATURE_SH_HISTFILESIZE |
16477 | hp = lookupvar("HISTFILESIZE"); | 16503 | hp = lookupvar("HISTSIZE"); |
16504 | /* Using HISTFILESIZE above to limit max_history would be WRONG: | ||
16505 | * users may set HISTFILESIZE=0 in their profile scripts | ||
16506 | * to prevent _saving_ of history files, but still want to have | ||
16507 | * non-zero history limit for in-memory list. | ||
16508 | */ | ||
16478 | line_input_state->max_history = size_from_HISTFILESIZE(hp); | 16509 | line_input_state->max_history = size_from_HISTFILESIZE(hp); |
16479 | # endif | 16510 | # endif |
16480 | } | 16511 | } |