ash,hush: print sugnal-related "beautification" (^C etc) to stderr, not stdout

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko committed 2026-10-11 15:54:21 +02:00
1 parent 1c7e871e0a
commit 049ae38950
2 files changed
+6 -6

No files matched your search

+3 -3
View File
@@ -11543,11 +11543,11 @@ preadfd(void)
INTOFF; /* no longjmp'ing out of read_line_input please */
nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ);
if (bb_got_signal == SIGINT)
write(STDOUT_FILENO, "^C\n", 3);
write(STDERR_FILENO, "^C\n", 3);
INTON; /* here non-blocked SIGINT will longjmp */
if (nr == 0) {
/* ^C pressed, "convert" to SIGINT */
write(STDOUT_FILENO, "^C\n", 3);
write(STDERR_FILENO, "^C\n", 3);
raise(SIGINT); /* here non-blocked SIGINT will longjmp */
/* raise(SIGINT) did not work! (e.g. if SIGINT
* is SIG_IGNed on startup, it stays SIG_IGNed)
@@ -11569,7 +11569,7 @@ preadfd(void)
}
else if (errno == EINTR) { /* got signal? */
if (bb_got_signal != SIGINT)
write(STDOUT_FILENO, "\n", 1);
write(STDERR_FILENO, "\n", 1);
goto empty_line_input;
}
# if ENABLE_ASH_IDLE_TIMEOUT
+3 -3
View File
@@ -2844,7 +2844,7 @@ static int show_prompt_and_get_stdin(struct in_str *i)
* both on keyboard ^C and on real SIGINT (non-kbd generated).
*/
if (sigismember(&G.pending_set, SIGINT)) {
write(STDOUT_FILENO, "^C\n", 3);
write(STDERR_FILENO, "^C\n", 3);
G.last_exitcode = 128 | SIGINT;
}
check_and_run_traps();
@@ -2855,7 +2855,7 @@ static int show_prompt_and_get_stdin(struct in_str *i)
if (!bb_got_signal) {
/* r < 0: ^D/EOF/error detected (but not signal) */
/* ^D on interactive input goes to next line before exiting: */
write(STDOUT_FILENO, "\n", 1);
write(STDERR_FILENO, "\n", 1);
i->p = NULL;
i->peek_buf[0] = r = EOF;
return r;
@@ -2895,7 +2895,7 @@ static int show_prompt_and_get_stdin(struct in_str *i)
/* ^C or SIGINT: repeat */
/* bash prints ^C even on real SIGINT (non-kbd generated) */
/* kernel prints "^C" itself, just print newline: */
write(STDOUT_FILENO, "\n", 1);
write(STDERR_FILENO, "\n", 1);
G.last_exitcode = 128 | SIGINT;
}
}