aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-04 21:21:32 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-05 15:43:35 +0100
commit17c5472c5a3eb548e9d06555a8863f83eaee9f26 (patch)
tree5c18e010bfe2d22fec0b87b58f983299b561a140 /miscutils
parentd70d4a023586b9e9835258acda58cdfaf9131e5e (diff)
downloadbusybox-17c5472c5a3eb548e9d06555a8863f83eaee9f26.tar.gz
bc: switch to SA_RESTART signal handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 15089314f..148e340a5 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -7121,7 +7121,23 @@ static BcStatus bc_vm_run(int argc, char *argv[],
if (G.ttyin) {
#if ENABLE_FEATURE_BC_SIGNALS
- signal_no_SA_RESTART_empty_mask(SIGINT, record_signo);
+ // With SA_RESTART, most system calls will restart
+ // (IOW: they won't fail with EINTR).
+ // In particular, this means ^C won't cause
+ // stdout to get into "error state" if SIGINT hits
+ // within write() syscall.
+ // The downside is that ^C while line input is taken
+ // will only be handled after [Enter] since read()
+ // from stdin is not interrupted by ^C either,
+ // it restarts, thus fgetc() does not return on ^C.
+ signal_SA_RESTART_empty_mask(SIGINT, record_signo);
+
+ // Without SA_RESTART, this exhibits a bug:
+ // "while (1) print 1" and try ^C-ing it.
+ // Intermittently, instead of returning to input line,
+ // you'll get "output error: Interrupted system call"
+ // and exit.
+ //signal_no_SA_RESTART_empty_mask(SIGINT, record_signo);
#endif
if (!(option_mask32 & BC_FLAG_Q))
bc_vm_info();