← Commit list

17c5472c5

Denys Vlasenko
Denys Vlasenko
2018-12-05
SUCCESS Duration: 151s

Subject

bc: switch to SA_RESTART signal handling

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

miscutils/bc.c+17 -1
@@ -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();