diff options
| author | Ron Yorston <rmy@pobox.com> | 2025-10-06 09:22:24 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2025-10-06 09:22:24 +0100 |
| commit | 96ed35e1bebb39ee0af657847879d5bcc4a6ee0c (patch) | |
| tree | 78ef2fb59df72f23cd5fff9b71265345b19b5d8b /shell/ash.c | |
| parent | 3b6192619de7b98db5155dbcfe4038355d97cdac (diff) | |
| download | busybox-w32-96ed35e1bebb39ee0af657847879d5bcc4a6ee0c.tar.gz busybox-w32-96ed35e1bebb39ee0af657847879d5bcc4a6ee0c.tar.bz2 busybox-w32-96ed35e1bebb39ee0af657847879d5bcc4a6ee0c.zip | |
ash: output '^C' when wait builtin is interrupted
When the wait builtin detects an interrupt it should print '^C' to
stdout, as is done in other similar cases.
Saves 16 bytes in the 64-bit build.
Diffstat (limited to '')
| -rw-r--r-- | shell/ash.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c index ae49687da..4fa385d37 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -935,6 +935,14 @@ raise_exception(int e) | |||
| 935 | } while (0) | 935 | } while (0) |
| 936 | #endif | 936 | #endif |
| 937 | 937 | ||
| 938 | #if ENABLE_PLATFORM_MINGW32 | ||
| 939 | static void | ||
| 940 | write_ctrl_c(void) | ||
| 941 | { | ||
| 942 | write(STDOUT_FILENO, "^C", 2); | ||
| 943 | } | ||
| 944 | #endif | ||
| 945 | |||
| 938 | /* | 946 | /* |
| 939 | * Called when a SIGINT is received. (If the user specifies | 947 | * Called when a SIGINT is received. (If the user specifies |
| 940 | * that SIGINT is to be trapped or ignored using the trap builtin, then | 948 | * that SIGINT is to be trapped or ignored using the trap builtin, then |
| @@ -967,7 +975,7 @@ raise_interrupt(void) | |||
| 967 | } | 975 | } |
| 968 | #if ENABLE_PLATFORM_MINGW32 | 976 | #if ENABLE_PLATFORM_MINGW32 |
| 969 | if (iflag) | 977 | if (iflag) |
| 970 | write(STDOUT_FILENO, "^C", 2); | 978 | write_ctrl_c(); |
| 971 | #endif | 979 | #endif |
| 972 | /* bash: ^C even on empty command line sets $? */ | 980 | /* bash: ^C even on empty command line sets $? */ |
| 973 | exitstatus = SIGINT + 128; | 981 | exitstatus = SIGINT + 128; |
| @@ -5516,8 +5524,10 @@ waitcmd(int argc UNUSED_PARAM, char **argv) | |||
| 5516 | * not "if (dowait() < 0)"! | 5524 | * not "if (dowait() < 0)"! |
| 5517 | */ | 5525 | */ |
| 5518 | #if ENABLE_PLATFORM_MINGW32 | 5526 | #if ENABLE_PLATFORM_MINGW32 |
| 5519 | if (waitcmd_int == 1) | 5527 | if (waitcmd_int == 1) { |
| 5528 | write_ctrl_c(); | ||
| 5520 | return 128 | SIGINT; | 5529 | return 128 | SIGINT; |
| 5530 | } | ||
| 5521 | waitcmd_int = 0; | 5531 | waitcmd_int = 0; |
| 5522 | #else | 5532 | #else |
| 5523 | if (pending_sig) | 5533 | if (pending_sig) |
| @@ -16031,7 +16041,7 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 16031 | } else if ((uintptr_t)r == 3) { | 16041 | } else if ((uintptr_t)r == 3) { |
| 16032 | /* ^C pressed, propagate event */ | 16042 | /* ^C pressed, propagate event */ |
| 16033 | if (trap[SIGINT]) { | 16043 | if (trap[SIGINT]) { |
| 16034 | write(STDOUT_FILENO, "^C", 2); | 16044 | write_ctrl_c(); |
| 16035 | pending_int = 1; | 16045 | pending_int = 1; |
| 16036 | dotrap(); | 16046 | dotrap(); |
| 16037 | if (!(rootshell && iflag)) | 16047 | if (!(rootshell && iflag)) |
