From: Ken Hornstein Date: Fri, 27 Jan 2012 18:34:17 +0000 (-0500) Subject: Convert to the use of siglongjmp() X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=77a8a873bf6678bc2c36a5839da714c5620683b6;p=mmh Convert to the use of siglongjmp() --- diff --git a/sbr/getans.c b/sbr/getans.c index 95e34c4..682a3b1 100644 --- a/sbr/getans.c +++ b/sbr/getans.c @@ -13,7 +13,7 @@ #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 (!(m_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); }