commit a14557fd6ea99a03bdba470811639fa16d98d219
parent 284fc8a130e6c5ce6ebcc4b663557e901dc5d9a4
Author: Ed van Bruggen <edvb@uw.edu>
Date: Thu, 12 Mar 2020 00:42:44 -0700
Prevent REPL from being terminated with CTRL+C
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/main.c b/main.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include <libgen.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -13,6 +14,13 @@
tsp_include_tib(string);
#endif
+/* stop program from being terminated with CTRL+C */
+void
+handler_sigint(int sig)
+{
+ sig = sig; /* prevent compiler warnings */
+}
+
int
main(int argc, char *argv[])
{
@@ -29,6 +37,8 @@ main(int argc, char *argv[])
tisp_env_lib(st, libs_tsp);
#endif
+ signal(SIGINT, handler_sigint);
+
if (argc == 1) {
st->file = "(repl)";
goto readstr;