aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-02-14 11:50:47 +0000
committerRon Yorston <rmy@pobox.com>2021-02-14 11:52:04 +0000
commit0168043f32e0ed03e3742d0b5768c49c1df27bff (patch)
tree270c26dfea25df9a7f18e27ea7c74cc959a2f188
parent3e460d91bd365b58860112fa1b517604f19ebbdf (diff)
downloadbusybox-w32-0168043f32e0ed03e3742d0b5768c49c1df27bff.tar.gz
busybox-w32-0168043f32e0ed03e3742d0b5768c49c1df27bff.tar.bz2
busybox-w32-0168043f32e0ed03e3742d0b5768c49c1df27bff.zip
bc: handle ^C in interactive mode
-rw-r--r--miscutils/bc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 046bad98e..38ae7f7d1 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -7399,6 +7399,17 @@ static unsigned xc_vm_envLen(const char *var)
7399 return len; 7399 return len;
7400} 7400}
7401 7401
7402#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_BC_INTERACTIVE
7403static BOOL WINAPI ctrl_handler(DWORD dwCtrlType)
7404{
7405 if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) {
7406 bb_got_signal = SIGINT;
7407 return TRUE;
7408 }
7409 return FALSE;
7410}
7411#endif
7412
7402static int xc_vm_init(const char *env_len) 7413static int xc_vm_init(const char *env_len)
7403{ 7414{
7404 G.prog.len = xc_vm_envLen(env_len); 7415 G.prog.len = xc_vm_envLen(env_len);
@@ -7426,6 +7437,8 @@ static int xc_vm_init(const char *env_len)
7426 // (This problem manifests only if line editing is disabled) 7437 // (This problem manifests only if line editing is disabled)
7427# if !ENABLE_PLATFORM_MINGW32 7438# if !ENABLE_PLATFORM_MINGW32
7428 signal_SA_RESTART_empty_mask(SIGINT, record_signo); 7439 signal_SA_RESTART_empty_mask(SIGINT, record_signo);
7440# else
7441 SetConsoleCtrlHandler(ctrl_handler, TRUE);
7429# endif 7442# endif
7430 7443
7431 // Without SA_RESTART, this exhibits a bug: 7444 // Without SA_RESTART, this exhibits a bug: