X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fgetans.c;h=682a3b1489f5b835bee88287a2f5bbb714138c63;hb=77a8a873bf6678bc2c36a5839da714c5620683b6;hp=173e1b43dec92689b4ff779c1833ab5d7282f5c2;hpb=3a84d814004fd4557bf4f44952648e9e69bd22a8;p=mmh diff --git a/sbr/getans.c b/sbr/getans.c index 173e1b4..682a3b1 100644 --- a/sbr/getans.c +++ b/sbr/getans.c @@ -9,11 +9,11 @@ #include #include -#include +#include #include static char ansbuf[BUFSIZ]; -static jmp_buf sigenv; +static sigjmp_buf sigenv; /* * static prototypes @@ -28,10 +28,11 @@ getans (char *prompt, struct swit *ansp) SIGNAL_HANDLER istat = NULL; char *cp, **cpp; - if (!(setjmp (sigenv))) { + if (!(sigsetjmp(sigenv, 1))) { istat = SIGNAL (SIGINT, intrser); } else { SIGNAL (SIGINT, istat); + printf("returning NULL\n"); return NULL; } @@ -40,8 +41,10 @@ getans (char *prompt, struct swit *ansp) fflush (stdout); cp = ansbuf; while ((i = getchar ()) != '\n') { - if (i == EOF) - longjmp (sigenv, 1); + if (i == EOF) { + printf("Got EOF\n"); + siglongjmp (sigenv, 1); + } if (cp < &ansbuf[sizeof ansbuf - 1]) *cp++ = i; } @@ -75,5 +78,5 @@ intrser (int i) /* * should this be siglongjmp? */ - longjmp (sigenv, 1); + siglongjmp (sigenv, 1); }