diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-13 01:05:03 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-13 01:15:10 +0100 |
commit | 68b402ee51f12f8c3b11638b042f57e025359faf (patch) | |
tree | f7db9b14b44d89c448fd7d35cae821a97695f7f3 /shell | |
parent | d162a7b978a98b910e410dc10a40d5de12db0419 (diff) | |
download | busybox-w32-68b402ee51f12f8c3b11638b042f57e025359faf.tar.gz busybox-w32-68b402ee51f12f8c3b11638b042f57e025359faf.tar.bz2 busybox-w32-68b402ee51f12f8c3b11638b042f57e025359faf.zip |
ash: ^C with SIG_INGed SIGINT should not exit the shell
function old new delta
__pgetc 501 522 +21
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index 4c5dd1298..12b2db3a9 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -10784,18 +10784,24 @@ preadfd(void) | |||
10784 | line_input_state->path_lookup = pathval(); | 10784 | line_input_state->path_lookup = pathval(); |
10785 | # endif | 10785 | # endif |
10786 | reinit_unicode_for_ash(); | 10786 | reinit_unicode_for_ash(); |
10787 | again: | ||
10787 | nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ); | 10788 | nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ); |
10788 | if (nr == 0) { | 10789 | if (nr == 0) { |
10789 | /* ^C pressed, "convert" to SIGINT */ | 10790 | /* ^C pressed, "convert" to SIGINT */ |
10790 | write(STDOUT_FILENO, "^C", 2); | 10791 | write(STDOUT_FILENO, "^C", 2); |
10791 | raise(SIGINT); | 10792 | raise(SIGINT); |
10793 | /* raise(SIGINT) did not work! (e.g. if SIGINT | ||
10794 | * is SIG_INGed on startup, it stays SIG_IGNed) | ||
10795 | */ | ||
10792 | if (trap[SIGINT]) { | 10796 | if (trap[SIGINT]) { |
10793 | buf[0] = '\n'; | 10797 | buf[0] = '\n'; |
10794 | buf[1] = '\0'; | 10798 | buf[1] = '\0'; |
10795 | return 1; | 10799 | return 1; |
10796 | } | 10800 | } |
10797 | exitstatus = 128 + SIGINT; | 10801 | exitstatus = 128 + SIGINT; |
10798 | return -1; | 10802 | /* bash behavior on ^C + ignored SIGINT: */ |
10803 | write(STDOUT_FILENO, "\n", 1); | ||
10804 | goto again; | ||
10799 | } | 10805 | } |
10800 | if (nr < 0) { | 10806 | if (nr < 0) { |
10801 | if (errno == 0) { | 10807 | if (errno == 0) { |