summaryrefslogtreecommitdiffstats
path: root/usr.bin/dc
diff options
context:
space:
mode:
authorgabor <gabor@FreeBSD.org>2010-06-06 11:36:08 +0000
committergabor <gabor@FreeBSD.org>2010-06-06 11:36:08 +0000
commit1a0d1f33835b644df56baa59f295df363e168874 (patch)
treef8976692f4439333d24defe632c7d5892cfbdc2f /usr.bin/dc
parent76c8a3922dee033069971e3d1c1f0a54b42fe9b5 (diff)
downloadFreeBSD-src-1a0d1f33835b644df56baa59f295df363e168874.zip
FreeBSD-src-1a0d1f33835b644df56baa59f295df363e168874.tar.gz
- Fix signal handling in bc/dc. Now Ctrl-C terminates the execution.
Requested by: gk (via private mail) Approved by: delphij (mentor)
Diffstat (limited to 'usr.bin/dc')
-rw-r--r--usr.bin/dc/bcode.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c
index e80c635..408a948 100644
--- a/usr.bin/dc/bcode.c
+++ b/usr.bin/dc/bcode.c
@@ -44,7 +44,6 @@ struct bmachine {
struct source *readstack;
struct stack *reg;
struct stack stack;
- volatile sig_atomic_t interrupted;
u_int scale;
u_int obase;
u_int ibase;
@@ -55,7 +54,7 @@ struct bmachine {
};
static struct bmachine bmachine;
-static void sighandler(int);
+static void got_sigint(int);
static __inline int readch(void);
static __inline void unreadch(void);
@@ -223,14 +222,11 @@ static const struct jump_entry jump_table_data[] = {
(sizeof(jump_table_data)/sizeof(jump_table_data[0]))
static void
-sighandler(int ignored)
+got_sigint(int ignored __unused)
{
- switch (ignored)
- {
- default:
- bmachine.interrupted = true;
- }
+ putchar('\n');
+ exit(0);
}
void
@@ -265,7 +261,7 @@ init_bmachine(bool extended_registers)
bmachine.obase = bmachine.ibase = 10;
BN_init(&zero);
bn_check(BN_zero(&zero));
- signal(SIGINT, sighandler);
+ signal(SIGINT, got_sigint);
}
/* Reset the things needed before processing a (new) file */
@@ -1746,14 +1742,6 @@ eval(void)
bmachine.readsp--;
continue;
}
- if (bmachine.interrupted) {
- if (bmachine.readsp > 0) {
- src_free();
- bmachine.readsp--;
- continue;
- } else
- bmachine.interrupted = false;
- }
#ifdef DEBUGGING
fprintf(stderr, "# %c\n", ch);
stack_print(stderr, &bmachine.stack, "* ",
OpenPOWER on IntegriCloud