void mal_exit(void){ str err; /* * Before continuing we should make sure that all clients * (except the console) have left the scene. */ MCstopClients(0); #if 0 { int reruns=0, go_on; do{ if ( (go_on = MCactiveClients()) ) MT_sleep_ms(1000); mnstr_printf(mal_clients->fdout,"#MALexit: %d clients still active\n", go_on); } while (++reruns < SERVERSHUTDOWNDELAY && go_on > 1); } #endif stopHeartbeat(); #ifdef HAVE_JSONSTORE stopHttpdaemon(); #endif stopMALdataflow(); stopProfiling(); RECYCLEdrop(mal_clients); /* remove any left over intermediates */ unloadLibraries(); #if 0 /* skip this to solve random crashes, needs work */ freeModuleList(mal_clients->nspace); finishNamespace(); if( mal_clients->prompt) GDKfree(mal_clients->prompt); if( mal_clients->errbuf) GDKfree(mal_clients->errbuf); if( mal_clients->bak) GDKfree(mal_clients->bak); if( mal_clients->fdin){ /* missing protection against closing stdin stream */ (void) mnstr_close(mal_clients->fdin->s); (void) bstream_destroy(mal_clients->fdin); } if( mal_clients->fdout && mal_clients->fdout != GDKstdout) { (void) mnstr_close(mal_clients->fdout); (void) mnstr_destroy(mal_clients->fdout); } #endif /* deregister everything that was registered, ignore errors */ if ((err = msab_wildRetreat()) != NULL) { fprintf(stderr, "!%s", err); free(err); } /* the server will now be shut down */ if ((err = msab_registerStop()) != NULL) { fprintf(stderr, "!%s", err); free(err); } GDKexit(0); /* properly end GDK */ }
/* coverity[+kill] */ int GDKfatal(const char *format, ...) { char message[GDKERRLEN]; size_t len = strlen(GDKFATAL); va_list ap; GDKdebug |= IOMASK; #ifndef NATIVE_WIN32 BATSIGinit(); #endif if (!strncmp(format, GDKFATAL, len)) { len = 0; } else { strcpy(message, GDKFATAL); } va_start(ap, format); vsnprintf(message + len, sizeof(message) - (len + 2), format, ap); va_end(ap); fputs(message, stderr); fputs("\n", stderr); fflush(stderr); /* * Real errors should be saved in the lock file for post-crash * inspection. */ if (GDKexiting()) { fflush(stdout); MT_exit_thread(1); /* exit(1); */ } else { GDKlog("%s", message); #ifdef COREDUMP abort(); #else GDKexit(1); #endif } return -1; }
static void BATSIGinterrupt(int nr) { GDKexit(nr); }
static void BATSIGabort(int nr) { GDKexit(3); /* emulate Windows exit code without pop-up */ }