From 77a8a873bf6678bc2c36a5839da714c5620683b6 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Fri, 27 Jan 2012 13:34:17 -0500 Subject: [PATCH] Convert to the use of siglongjmp() --- sbr/getans.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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); } -- 1.7.10.4