remove longjmp from signalhandler in getans
authorPhilipp Takacs <philipp@bureaucracy.de>
Sat, 21 Feb 2015 10:03:26 +0000 (11:03 +0100)
committerPhilipp Takacs <philipp@bureaucracy.de>
Sun, 22 Feb 2015 22:10:00 +0000 (23:10 +0100)
To avoid undefined behavior use close in the signal handler.

sbr/getans.c

index 7254d6b..f3cea27 100644 (file)
@@ -10,6 +10,7 @@
 #include <h/signals.h>
 #include <setjmp.h>
 #include <signal.h>
+#include <unistd.h>
 
 static char ansbuf[BUFSIZ];
 static jmp_buf sigenv;
@@ -72,5 +73,5 @@ intrser(int i)
        /*
        ** should this be siglongjmp?
        */
-       longjmp(sigenv, 1);
+       close(STDIN_FILENO);
 }