mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-01-06 02:23:59 +00:00
1. Fixed compiler warning
2. Updated so process.exit() throws exception when called in agent mode
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
// This file is auto-generated, any edits may be overwritten
|
||||
#define SOURCE_COMMIT_DATE NULL
|
||||
#define SOURCE_COMMIT_HASH NULL
|
||||
#define SOURCE_COMMIT_DATE "2019-May-12 21:39:02-0700"
|
||||
#define SOURCE_COMMIT_HASH "d0fb36d10bc2bdf6822629daa098b07a90730e88"
|
||||
|
||||
@@ -491,22 +491,30 @@ duk_ret_t ILibDuktape_ScriptContainer_Process_Exit(duk_context *ctx)
|
||||
void **tmp;
|
||||
int nargs = duk_get_top(ctx);
|
||||
|
||||
duk_push_this(ctx); // [process]
|
||||
if (nargs == 1)
|
||||
if (duk_peval_string(ctx, "require('MeshAgent').agentMode") == 0 && duk_get_boolean(ctx, -1))
|
||||
{
|
||||
duk_push_int(ctx, duk_require_int(ctx, 0)); // [process][code]
|
||||
duk_put_prop_string(ctx, -2, ILibDuktape_ScriptContainer_ExitCode); // [process]
|
||||
// Running in Agent Mode, so exiting process is not allowed
|
||||
return(ILibDuktape_Error(ctx, "Process.exit() not allowed when running in Agent Mode"));
|
||||
}
|
||||
if (duk_has_prop_string(ctx, -1, ILibDuktape_ScriptContainer_Exitting)) { return(ILibDuktape_Error(ctx, "Process.exit() forced script termination")); }
|
||||
duk_push_int(ctx, 1);
|
||||
duk_put_prop_string(ctx, -2, ILibDuktape_ScriptContainer_Exitting); // [process]
|
||||
else
|
||||
{
|
||||
duk_push_this(ctx); // [process]
|
||||
if (nargs == 1)
|
||||
{
|
||||
duk_push_int(ctx, duk_require_int(ctx, 0)); // [process][code]
|
||||
duk_put_prop_string(ctx, -2, ILibDuktape_ScriptContainer_ExitCode); // [process]
|
||||
}
|
||||
if (duk_has_prop_string(ctx, -1, ILibDuktape_ScriptContainer_Exitting)) { return(ILibDuktape_Error(ctx, "Process.exit() forced script termination")); }
|
||||
duk_push_int(ctx, 1);
|
||||
duk_put_prop_string(ctx, -2, ILibDuktape_ScriptContainer_Exitting); // [process]
|
||||
|
||||
|
||||
// Execute this later, so that this stack can unwind first, before we destroy the heap
|
||||
tmp = (void**)Duktape_PushBuffer(ctx, sizeof(void*)); // [process][buffer]
|
||||
duk_put_prop_string(ctx, -2, "\xFF_JUNK"); // [process]
|
||||
tmp[0] = ctx;
|
||||
ILibLifeTime_Add(ILibGetBaseTimer(Duktape_GetChain(ctx)), tmp, 0, ILibDuktape_ScriptContainer_Process_ExitCallback, NULL);
|
||||
// Execute this later, so that this stack can unwind first, before we destroy the heap
|
||||
tmp = (void**)Duktape_PushBuffer(ctx, sizeof(void*)); // [process][buffer]
|
||||
duk_put_prop_string(ctx, -2, "\xFF_JUNK"); // [process]
|
||||
tmp[0] = ctx;
|
||||
ILibLifeTime_Add(ILibGetBaseTimer(Duktape_GetChain(ctx)), tmp, 0, ILibDuktape_ScriptContainer_Process_ExitCallback, NULL);
|
||||
}
|
||||
return(ILibDuktape_Error(ctx, "Process.exit() forced script termination"));
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,6 @@ typedef struct SCRIPT_ENGINE_SETTINGS
|
||||
char *argList[];
|
||||
}SCRIPT_ENGINE_SETTINGS;
|
||||
|
||||
|
||||
void ILibDuktape_ScriptContainer_CheckEmbedded(char **script, int *scriptLen);
|
||||
void ILibDuktape_ScriptContainer_CheckEmbeddedEx(char *exePath, char **script, int *scriptLen);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user