From ead95fb0d4db48ed307750c7b3d8f417e6d2f308 Mon Sep 17 00:00:00 2001 From: vsc Date: Wed, 23 Oct 2002 20:55:37 +0000 Subject: [PATCH] fix warnings; improve SIGINT handling if !isastty git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@651 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/alloc.c | 4 ++-- C/errors.c | 11 ++++++++++- C/sysbits.c | 6 +++--- m4/Yap.h.m4 | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/C/alloc.c b/C/alloc.c index e95d49400..33e7eee31 100644 --- a/C/alloc.c +++ b/C/alloc.c @@ -12,7 +12,7 @@ * Last rev: * * mods: * * comments: allocating space * -* version:$Id: alloc.c,v 1.25 2002-10-21 22:14:28 vsc Exp $ * +* version:$Id: alloc.c,v 1.26 2002-10-23 20:55:36 vsc Exp $ * *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; @@ -976,7 +976,7 @@ ExtendWorkSpace(Int s) if ((CELL)ptr & MBIT) { ErrorMessage = ErrorSay; snprintf5(ErrorMessage, MAX_ERROR_MSG_SIZE, - "memory at %p conflicts with MBIT %lx", ptr, MBIT); + "memory at %p conflicts with MBIT %lx", ptr, (unsigned long)MBIT); PrologMode = OldPrologMode; return(FALSE); } diff --git a/C/errors.c b/C/errors.c index a991c2546..10163835b 100644 --- a/C/errors.c +++ b/C/errors.c @@ -362,7 +362,12 @@ Error (yap_error_number type, Term where, char *format,...) int serious; char *tp = tmpbuf; int psize = YAP_BUF_SIZE; - + + if (type == INTERRUPT_ERROR) { + fprintf(stderr,"[ YAP exiting: cannot handle signal %d ]\n", + (int)IntOfTerm(where)); + exit_yap(1); + } /* disallow recursive error handling */ if (PrologMode & InErrorMode) { /* error within error */ @@ -454,6 +459,10 @@ Error (yap_error_number type, Term where, char *format,...) fprintf(stderr,"[ Fatal YAP Error: %s exiting.... ]\n",tmpbuf); error_exit_yap (1); } + case INTERRUPT_ERROR: + { + error_exit_yap (1); + } case PURE_ABORT: nt[0] = MkAtomTerm(LookupAtom(tmpbuf)); fun = MkFunctor(LookupAtom("abort"),2); diff --git a/C/sysbits.c b/C/sysbits.c index 38cfdde26..ddd54dba3 100644 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -1218,9 +1218,10 @@ HandleSIGINT (int sig) #endif { my_signal(SIGINT, HandleSIGINT); + /* do this before we act */ #if HAVE_ISATTY if (!isatty(0)) { - InteractSIGINT('e'); + Error(INTERRUPT_ERROR,MkIntTerm(SIGINT),NULL); } #endif if (PrologMode & (CritMode|ConsoleGetcMode)) { @@ -1290,8 +1291,7 @@ ReceiveSignal (int s) /* These signals are not handled by WIN32 and not the Macintosh */ case SIGQUIT: case SIGKILL: - YP_fprintf(YP_stderr, "\n\n\n[ Quit signal received ]\n\n"); - exit_yap (SIGKILL); + Error(INTERRUPT_ERROR,MkIntTerm(s),NULL); #endif #if defined(SIGUSR1) case SIGUSR1: diff --git a/m4/Yap.h.m4 b/m4/Yap.h.m4 index 07a923814..5edd69dad 100644 --- a/m4/Yap.h.m4 +++ b/m4/Yap.h.m4 @@ -10,7 +10,7 @@ * File: Yap.h.m4 * * mods: * * comments: main header file for YAP * -* version: $Id: Yap.h.m4,v 1.34 2002-10-21 22:14:29 vsc Exp $ * +* version: $Id: Yap.h.m4,v 1.35 2002-10-23 20:55:37 vsc Exp $ * *************************************************************************/ #include "config.h" @@ -437,6 +437,7 @@ typedef enum { EXISTENCE_ERROR_SOURCE_SINK, EXISTENCE_ERROR_STREAM, INSTANTIATION_ERROR, + INTERRUPT_ERROR, OUT_OF_HEAP_ERROR, OUT_OF_STACK_ERROR, OUT_OF_TRAIL_ERROR,