aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2022-01-13 01:05:03 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2022-01-13 01:15:10 +0100
commit68b402ee51f12f8c3b11638b042f57e025359faf (patch)
treef7db9b14b44d89c448fd7d35cae821a97695f7f3
parentd162a7b978a98b910e410dc10a40d5de12db0419 (diff)
downloadbusybox-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>
-rw-r--r--loginutils/login.c4
-rw-r--r--loginutils/sulogin.c5
-rw-r--r--shell/ash.c8
3 files changed, 15 insertions, 2 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index 569053c12..cac4349b2 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -608,7 +608,9 @@ int login_main(int argc UNUSED_PARAM, char **argv)
608 * But without this, bash 3.0 will not enable ctrl-c either. 608 * But without this, bash 3.0 will not enable ctrl-c either.
609 * Maybe bash is buggy? 609 * Maybe bash is buggy?
610 * Need to find out what standards say about /bin/login - 610 * Need to find out what standards say about /bin/login -
611 * should we leave SIGINT etc enabled or disabled? */ 611 * should we leave SIGINT etc enabled or disabled?
612 * Also note: sulogin does not do it! Why?
613 */
612 signal(SIGINT, SIG_DFL); 614 signal(SIGINT, SIG_DFL);
613 615
614 /* Exec login shell with no additional parameters */ 616 /* Exec login shell with no additional parameters */
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 5f1c1178f..2f87c77c0 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -111,6 +111,11 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
111 } 111 }
112 } 112 }
113 113
114 /*
115 * Note: login does this (should we do it too?):
116 */
117 /*signal(SIGINT, SIG_DFL);*/
118
114 /* Exec login shell with no additional parameters. Never returns. */ 119 /* Exec login shell with no additional parameters. Never returns. */
115 exec_login_shell(shell); 120 exec_login_shell(shell);
116} 121}
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) {