/* * Exit the mpr gracefully. Instruct the event loop to exit. */ void mprTerminate(MprCtx ctx, bool graceful) { if (! graceful) { exit(0); } mprSignalExit(ctx); }
void mprFatalError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...) { va_list args; char *buf; int len; va_start(args, fmt); len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args); va_end(args); logOutput(MPR_LOC_PASS(ctx, loc), MPR_USER_MSG | MPR_FATAL_SRC, 0, buf); mprFree(buf); #if BREW mprSignalExit(ctx); #else exit(2); #endif }
static long msgProc(HWND hwnd, uint msg, uint wp, long lp) { char buf[MPR_MAX_FNAME]; switch (msg) { case WM_DESTROY: case WM_QUIT: mprSignalExit(mpr); break; case APPWEB_MONITOR_MESSAGE: return monitorEvent(hwnd, wp, lp); case WM_COMMAND: switch (LOWORD(wp)) { case MA_MENU_STATUS: break; case MA_MENU_DOC: runBrowser("/doc/index.html"); break; case MA_MENU_MANAGE: runBrowser("/index.html"); break; case MA_MENU_START: startService(); break; case MA_MENU_STOP: stopService(); break; case MA_MENU_ABOUT: /* * Single-threaded users beware. This blocks !! */ mprSprintf(buf, sizeof(buf), "%s %s-%s", BLD_NAME, BLD_VERSION, BLD_NUMBER); MessageBoxEx(NULL, buf, mprGetAppTitle(mpr), MB_OK, 0); break; case MA_MENU_EXIT: /* * FUTURE * * h = CreateDialog(appInst, MAKEINTRESOURCE(IDD_EXIT), appHwnd, dialogProc); * ShowWindow(h, SW_SHOW); */ PostMessage(hwnd, WM_QUIT, 0, 0L); break; default: return DefWindowProc(hwnd, msg, wp, lp); } break; default: return DefWindowProc(hwnd, msg, wp, lp); } return 0; }
/* * On a memory allocation failure, go into graceful degrade mode. Set all slab allocation chunk increments to 1 * so we can create an exception block to throw. */ void ejsGracefulDegrade(Ejs *ejs) { mprLog(ejs, 1, "WARNING: Memory almost depleted. In graceful degrade mode"); ejs->gc.degraded = 1; mprSignalExit(ejs); }