/* -----------------------------------------------------------------------------
- * $Id: Rts.h,v 1.10 2000/01/12 15:15:17 simonmar Exp $
+ * $Id: Rts.h,v 1.11 2000/01/13 12:40:15 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#include "Stg.h"
/* -----------------------------------------------------------------------------
- Miscellaneous garbage
+ RTS Exit codes
-------------------------------------------------------------------------- */
#if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
#define EXIT_FAILURE 1
#endif
+/* 255 is allegedly used by dynamic linkers to report linking failure */
+#define EXIT_INTERNAL_ERROR 254
+#define EXIT_DEADLOCK 253
+#define EXIT_INTERRUPTED 252
+#define EXIT_HEAPOVERFLOW 251
+#define EXIT_KILLED 250
+
+/* -----------------------------------------------------------------------------
+ Miscellaneous garbage
+ -------------------------------------------------------------------------- */
+
/* declarations for runtime flags/values */
#define MAX_RTS_ARGS 32
/* ----------------------------------------------------------------------------
- * $Id: RtsAPI.h,v 1.8 1999/11/02 15:05:52 simonmar Exp $
+ * $Id: RtsAPI.h,v 1.9 2000/01/13 12:40:15 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
Success,
Killed, /* another thread killed us */
Interrupted, /* stopped in response to a call to interruptStgRts */
- Deadlock,
- AllBlocked, /* subtly different from Deadlock */
+ Deadlock /* no threads to run, but main thread hasn't finished */
} SchedulerStatus;
-
+
typedef StgClosure *HaskellObj;
/* ----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Itimer.c,v 1.7 1999/12/01 14:19:36 simonmar Exp $
+ * $Id: Itimer.c,v 1.8 2000/01/13 12:40:15 simonmar Exp $
*
* (c) The GHC Team, 1995-1999
*
se.sigev_signo = SIGVTALRM;
se.sigev_value.sival_int = SIGVTALRM;
if (timer_create(CLOCK_VIRTUAL, &se, &tid)) {
- fprintf(stderr, "Can't create virtual timer.\n");
- EXIT(EXIT_FAILURE);
+ barf("can't create virtual timer");
}
it.it_value.tv_sec = ms / 1000;
it.it_value.tv_nsec = 1000000 * (ms - 1000 * it.it_value.tv_sec);
/* -----------------------------------------------------------------------------
- * $Id: Main.c,v 1.12 1999/11/02 15:05:58 simonmar Exp $
+ * $Id: Main.c,v 1.13 2000/01/13 12:40:15 simonmar Exp $
*
* (c) The GHC Team 1998-1999
*
# ifndef INTERPRETER /* Hack */
int main(int argc, char *argv[])
{
+ int exit_status;
+
SchedulerStatus status;
startupHaskell(argc,argv);
}
# endif /* PAR */
switch (status) {
- case AllBlocked:
- barf("Scheduler stopped, all threads blocked");
case Deadlock:
- shutdownHaskell();
- barf("No threads to run! Deadlock?");
+ prog_belch("no threads to run: infinite loop or deadlock?");
+ exit_status = EXIT_DEADLOCK;
+ break;
case Killed:
- belch("%s: warning: main thread killed", prog_argv[0]);
- case Success:
+ prog_belch("main thread killed");
+ exit_status = EXIT_KILLED;
+ break;
case Interrupted:
- /* carry on */
+ prog_belch("interrupted");
+ exit_status = EXIT_INTERRUPTED;
+ break;
+ case Success:
+ exit_status = EXIT_SUCCESS;
+ break;
+ case NoStatus:
+ barf("main thread completed with no status");
}
- shutdownHaskellAndExit(EXIT_SUCCESS);
+ shutdownHaskellAndExit(exit_status);
}
# endif /* BATCH_MODE */
/* -----------------------------------------------------------------------------
- * $Id: PrimOps.hc,v 1.37 2000/01/06 11:57:50 sewardj Exp $
+ * $Id: PrimOps.hc,v 1.38 2000/01/13 12:40:15 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#endif
if (info == &FULL_MVAR_info) {
- fprintf(stderr, "putMVar#: MVar already full.\n");
- stg_exit(EXIT_FAILURE);
+ barf("putMVar#: MVar already full");
}
mvar->value = R2.cl;
/* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.22 2000/01/12 15:15:17 simonmar Exp $
+ * $Id: RtsFlags.c,v 1.23 2000/01/13 12:40:15 simonmar Exp $
*
* (c) The AQUA Project, Glasgow University, 1994-1997
* (c) The GHC Team, 1998-1999
static void
bad_option(const char *s)
{
- fflush(stdout);
- fprintf(stderr, "initSM: Bad RTS option: %s\n", s);
+ prog_belch("bad RTS option: %s", s);
stg_exit(EXIT_FAILURE);
-}
+}
/* -----------------------------------------------------------------------------
- * $Id: RtsUtils.c,v 1.11 2000/01/12 15:15:17 simonmar Exp $
+ * $Id: RtsUtils.c,v 1.12 2000/01/13 12:40:16 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
fflush(stderr);
- stg_exit(EXIT_FAILURE);
+ stg_exit(EXIT_INTERNAL_ERROR);
}
void prog_belch(char *s, ...)
if ((space = (char *) malloc((size_t) n)) == NULL) {
/* don't fflush(stdout); WORKAROUND bug in Linux glibc */
- MallocFailHook((W_) n, msg); /*msg*/
- stg_exit(EXIT_FAILURE);
+ MallocFailHook((W_) n, msg); /*msg*/
+ stg_exit(EXIT_INTERNAL_ERROR);
}
return space;
}
if ((space = (char *) realloc(p, (size_t) n)) == NULL) {
/* don't fflush(stdout); WORKAROUND bug in Linux glibc */
- MallocFailHook((W_) n, msg); /*msg*/
- exit(EXIT_FAILURE);
+ MallocFailHook((W_) n, msg); /*msg*/
+ stg_exit(EXIT_INTERNAL_ERROR);
}
return space;
}
if (RtsFlags.TickyFlags.showTickyStats) PrintTickyInfo();
#endif
- stg_exit(EXIT_FAILURE);
+ stg_exit(EXIT_HEAPOVERFLOW);
}
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Select.c,v 1.6 2000/01/12 15:15:18 simonmar Exp $
+ * $Id: Select.c,v 1.7 2000/01/13 12:40:16 simonmar Exp $
*
* (c) The GHC Team 1995-1999
*
if (errno != EINTR) {
/* fflush(stdout); */
perror("select");
- fprintf(stderr, "awaitEvent: select failed\n");
- stg_exit(EXIT_FAILURE);
+ barf("select failed");
}
ACQUIRE_LOCK(&sched_mutex);
/* -----------------------------------------------------------------------------
- * $Id: Signals.c,v 1.11 2000/01/12 15:15:18 simonmar Exp $
+ * $Id: Signals.c,v 1.12 2000/01/13 12:40:16 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
if (handlers == NULL) {
/* don't fflush(stdout); WORKAROUND bug in Linux glibc */
- fprintf(stderr, "VM exhausted (in more_handlers)\n");
- exit(EXIT_FAILURE);
+ barf("VM exhausted (in more_handlers)");
}
for(i = nHandlers; i <= sig; i++)
/* Fill in the new slots with default actions */
sig_install(StgInt sig, StgInt spi, StgStablePtr handler, sigset_t *mask)
{
/* don't fflush(stdout); WORKAROUND bug in Linux glibc */
- fprintf(stderr,
- "No signal handling support in a parallel implementation.\n");
- exit(EXIT_FAILURE);
+ barf("no signal handling support in a parallel implementation");
}
void
} else
#endif
- shutdownHaskellAndExit(EXIT_FAILURE);
+ shutdownHaskellAndExit(EXIT_INTERRUPTED);
}
/*