1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-08 19:44:06 +00:00

1. Updated self-update logging to include current commit hash value

2. Updated child_process.waitExit() to throw an exception on empty set condition
3. Updated ILibChain_Continue() to exit while() loop on empty set
4. Updated agent-installer to better handle error conditions for updatervalue and meshservicename
This commit is contained in:
Bryan Roe
2021-01-13 11:13:37 -08:00
parent 6700428511
commit 78507ed66e
6 changed files with 164 additions and 94 deletions

View File

@@ -2574,6 +2574,14 @@ void MeshServer_selfupdate_continue(MeshAgentHostContainer *agent)
if (agent->performSelfUpdate == 0) { agent->performSelfUpdate = 999; } // Never allow this value to be zero.
#endif
if (duk_peval_string(agent->meshCoreCtx, "process.versions.commitHash") == 0)
{
ILIBLOGMESSAGEX("SelfUpdate -> Current Version: %s", duk_safe_to_string(agent->meshCoreCtx, -1));
}
duk_pop(agent->meshCoreCtx); // ...
if (duk_peval_string_noresult(agent->meshCoreCtx, "require('service-manager').manager.getService('meshagentDiagnostic').start();") == 0)
{
if (agent->logUpdate != 0)
@@ -2610,7 +2618,15 @@ void MeshServer_selfupdate_continue(MeshAgentHostContainer *agent)
}
else
{
ILIBLOGMESSAGEX("SelfUpdate -> UpdaterVersion_ERROR: %s", duk_safe_to_string(agent->meshCoreCtx, -1));
char *err = (char*)duk_safe_to_string(agent->meshCoreCtx, -1);
ILIBLOGMESSAGEX("SelfUpdate -> UpdaterVersion_ERROR: %s", err);
if (duk_ctx_is_alive(agent->meshCoreCtx))
{
duk_push_sprintf(agent->meshCoreCtx, "require('MeshAgent').SendCommand({ action: 'sessions', type : 'msg', value : { 1: { value: 'Self-Update -> ABORT: %s', icon : 3 } } });", err);
duk_eval_noresult(agent->meshCoreCtx);
}
duk_pop(agent->meshCoreCtx); // ...
return;
}
duk_pop(agent->meshCoreCtx); // ...
#endif
@@ -2660,12 +2676,7 @@ void MeshServer_selfupdate_continue(MeshAgentHostContainer *agent)
#endif
// Everything looks good, lets perform the update
if (agent->logUpdate != 0)
{
char tmp[255];
sprintf_s(tmp, sizeof(tmp), "SelfUpdate -> Stopping Chain (%d)", agent->performSelfUpdate);
ILIBLOGMESSSAGE(tmp);
}
ILIBLOGMESSAGEX("SelfUpdate -> Stopping Chain (%d)", agent->performSelfUpdate);
ILibStopChain(agent->chain);
}
duk_ret_t MeshServer_selfupdate_unzip_complete(duk_context *ctx)
@@ -3265,6 +3276,7 @@ void MeshServer_ProcessCommand(ILibWebClient_StateObject WebStateObject, MeshAge
case MeshCommand_AgentUpdateBlock:
{
// Write the mesh agent block to file
int retryCount = 0;
#ifdef WIN32
char* updateFilePath = MeshAgent_MakeAbsolutePath(agent->exePath, ".update.exe");
#else
@@ -3272,7 +3284,7 @@ void MeshServer_ProcessCommand(ILibWebClient_StateObject WebStateObject, MeshAge
#endif
// We have to try to write until it works, fopen sometimes fails
while (util_appendfile(updateFilePath, cmd + 4, cmdLen - 4) == 0)
while (util_appendfile(updateFilePath, cmd + 4, cmdLen - 4) == 0 && ++retryCount < 4)
{
#ifdef WIN32
Sleep(100);
@@ -3281,11 +3293,21 @@ void MeshServer_ProcessCommand(ILibWebClient_StateObject WebStateObject, MeshAge
#endif
}
// Confirm we got a mesh agent update block
((unsigned short*)ILibScratchPad2)[0] = htons(MeshCommand_AgentUpdateBlock); // MeshCommand_AgentHash (14), SHA384 hash of the agent executable
((unsigned short*)ILibScratchPad2)[1] = htons(requestid); // Request id
ILibWebClient_WebSocket_Send(WebStateObject, ILibWebClient_WebSocket_DataType_BINARY, ILibScratchPad2, 4, ILibAsyncSocket_MemoryOwnership_USER, ILibWebClient_WebSocket_FragmentFlag_Complete);
if (retryCount < 4)
{
// Confirm we got a mesh agent update block
((unsigned short*)ILibScratchPad2)[0] = htons(MeshCommand_AgentUpdateBlock); // MeshCommand_AgentHash (14), SHA384 hash of the agent executable
((unsigned short*)ILibScratchPad2)[1] = htons(requestid); // Request id
ILibWebClient_WebSocket_Send(WebStateObject, ILibWebClient_WebSocket_DataType_BINARY, ILibScratchPad2, 4, ILibAsyncSocket_MemoryOwnership_USER, ILibWebClient_WebSocket_FragmentFlag_Complete);
}
else
{
if (duk_ctx_is_alive(agent->meshCoreCtx))
{
// Update Failed, so update the server with an agent message explaining what happened, then abort the update by not sending an ACK
duk_eval_string_noresult(agent->meshCoreCtx, "require('MeshAgent').SendCommand({ action: 'sessions', type : 'msg', value : { 1: { value: 'Self-Update FAILED. Write Error while writing update block', icon : 3 } } });");
}
}
break;
}
}
@@ -3552,6 +3574,8 @@ void MeshServer_ConnectEx_NetworkError(void *j)
ILibMemory_Free(j);
if (agent->controlChannelDebug != 0) { ILIBLOGMESSAGEX("Network Timeout Occurred..."); }
agent->serverConnectionState = 0; // We are cancelling connection request
printf("Network Timeout occurred...\n");
ILibWebClient_CancelRequest(request);
@@ -5734,48 +5758,48 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
agentHost->chain = NULL; // Mesh agent has exited, set the chain to NULL
// Close the database
if (agentHost->masterDb != NULL)
if (agentHost->masterDb != NULL)
{
if (agentHost->performSelfUpdate != 0)
{
if (agentHost->JSRunningAsService == 0)
{
duk_context *ctxx = ILibDuktape_ScriptContainer_InitializeJavaScriptEngine_minimal();
duk_size_t jsonLen;
char *json = NULL;
duk_context *ctxx = ILibDuktape_ScriptContainer_InitializeJavaScriptEngine_minimal();
duk_size_t jsonLen;
char *json = NULL;
ILibDuktape_SimpleDataStore_raw_GetCachedValues_Array(ctxx, agentHost->masterDb); // [array]
if (duk_get_length(ctxx, -1) > 0)
ILibDuktape_SimpleDataStore_raw_GetCachedValues_Array(ctxx, agentHost->masterDb); // [array]
if (duk_get_length(ctxx, -1) > 0)
{
duk_json_encode(ctxx, -1); // [json]
json = (char*)duk_get_lstring(ctxx, -1, &jsonLen);
startParms = (char*)ILibMemory_SmartAllocateEx(jsonLen + 1, ILibBase64EncodeLength(jsonLen + 1));
unsigned char* tmp = (unsigned char*)ILibMemory_Extra(startParms);
memcpy_s(startParms, jsonLen + 1, json, jsonLen);
Duktape_SafeDestroyHeap(ctxx);
if (jsonLen > INT32_MAX)
{
duk_json_encode(ctxx, -1); // [json]
json = (char*)duk_get_lstring(ctxx, -1, &jsonLen);
startParms = (char*)ILibMemory_SmartAllocateEx(jsonLen + 1, ILibBase64EncodeLength(jsonLen + 1));
unsigned char* tmp = (unsigned char*)ILibMemory_Extra(startParms);
memcpy_s(startParms, jsonLen + 1, json, jsonLen);
Duktape_SafeDestroyHeap(ctxx);
if (jsonLen > INT32_MAX)
{
ILibMemory_Free(startParms);
startParms = NULL;
if (agentHost->logUpdate != 0) { ILIBLOGMESSAGEX(" Service Parameters => ERROR"); }
}
else
{
ILibBase64Encode((unsigned char*)startParms, (int)jsonLen, &tmp);
if (agentHost->logUpdate != 0) { ILIBLOGMESSAGEX(" Service Parameters => %s", startParms); }
}
ILibMemory_Free(startParms);
startParms = NULL;
if (agentHost->logUpdate != 0) { ILIBLOGMESSAGEX(" Service Parameters => ERROR"); }
}
else
{
if (agentHost->logUpdate != 0) { ILIBLOGMESSAGEX(" Service Parameters => NONE"); }
ILibBase64Encode((unsigned char*)startParms, (int)jsonLen, &tmp);
if (agentHost->logUpdate != 0) { ILIBLOGMESSAGEX(" Service Parameters => %s", startParms); }
}
}
else
{
if (agentHost->logUpdate != 0) { ILIBLOGMESSAGEX(" Service Parameters => NONE"); }
}
}
else
{
#ifdef WIN32
if(strcmp(agentHost->meshServiceName, "Mesh Agent") !=0)
if (strcmp(agentHost->meshServiceName, "Mesh Agent") != 0)
#else
if (strcmp(agentHost->meshServiceName, "meshagent") != 0)
#endif
@@ -5818,7 +5842,7 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
if (!CreateProcessW(NULL, ILibUTF8ToWide(ILibScratchPad, -1), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &info, &processInfo))
{
// We triedI to execute a bad executable... not good. Lets try to recover.
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> FAILED..."); }
ILIBLOGMESSSAGE("SelfUpdate -> FAILED...");
if (updateFilePath != NULL && agentHost->exePath != NULL)
{
while (util_CopyFile(agentHost->exePath, updateFilePath, FALSE) == FALSE) Sleep(5000);
@@ -5833,7 +5857,7 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
{
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
}
#else
if (agentHost->JSRunningAsService != 0)
{
@@ -5849,41 +5873,41 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
if (system(ILibScratchPad)) {}
switch (agentHost->platformType)
{
case MeshAgent_Posix_PlatformTypes_BSD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... [restarting service]"); }
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "service %s onerestart", agentHost->meshServiceName); // Restart the service
ignore_result(system(ILibScratchPad));
break;
case MeshAgent_Posix_PlatformTypes_LAUNCHD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... [kickstarting service]"); }
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "launchctl kickstart -k system/%s", agentHost->meshServiceName); // Restart the service
ignore_result(system(ILibScratchPad));
break;
case MeshAgent_Posix_PlatformTypes_SYSTEMD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... [SYSTEMD should auto-restart]"); }
exit(1);
break;
case MeshAgent_Posix_PlatformTypes_PROCD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... [PROCD should auto-restart]"); }
exit(1);
break;
case MeshAgent_Posix_PlatformTypes_INITD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... Calling Service restart (INITD)"); }
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "service %s restart", agentHost->meshServiceName); // Restart the service
ignore_result(MeshAgent_System(ILibScratchPad));
break;
case MeshAgent_Posix_PlatformTypes_INIT_UPSTART:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... Calling initctl restart (UPSTART)"); }
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "initctl restart %s", agentHost->meshServiceName); // Restart the service
ignore_result(MeshAgent_System(ILibScratchPad));
break;
default:
break;
case MeshAgent_Posix_PlatformTypes_BSD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... [restarting service]"); }
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "service %s onerestart", agentHost->meshServiceName); // Restart the service
ignore_result(system(ILibScratchPad));
break;
case MeshAgent_Posix_PlatformTypes_LAUNCHD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... [kickstarting service]"); }
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "launchctl kickstart -k system/%s", agentHost->meshServiceName); // Restart the service
ignore_result(system(ILibScratchPad));
break;
case MeshAgent_Posix_PlatformTypes_SYSTEMD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... [SYSTEMD should auto-restart]"); }
exit(1);
break;
case MeshAgent_Posix_PlatformTypes_PROCD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... [PROCD should auto-restart]"); }
exit(1);
break;
case MeshAgent_Posix_PlatformTypes_INITD:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... Calling Service restart (INITD)"); }
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "service %s restart", agentHost->meshServiceName); // Restart the service
ignore_result(MeshAgent_System(ILibScratchPad));
break;
case MeshAgent_Posix_PlatformTypes_INIT_UPSTART:
if (agentHost->logUpdate != 0) { ILIBLOGMESSSAGE("SelfUpdate -> Complete... Calling initctl restart (UPSTART)"); }
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "initctl restart %s", agentHost->meshServiceName); // Restart the service
ignore_result(MeshAgent_System(ILibScratchPad));
break;
default:
break;
}
}
else
{
if (agentHost->logUpdate != 0)
if (agentHost->logUpdate != 0)
{
ILIBLOGMESSSAGE("SelfUpdate -> Service Check... [NO]");
ILIBLOGMESSSAGE("SelfUpdate -> Manual Mode (COMPLETE)");
@@ -5908,7 +5932,7 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
}
if (startParms != NULL) { ILibMemory_Free(startParms); }
#ifndef MICROSTACK_NOTLS
util_openssl_uninit();
#endif

View File

@@ -187,6 +187,8 @@ duk_ret_t ILibDuktape_ChildProcess_Kill(duk_context *ctx)
}
duk_ret_t ILibDuktape_ChildProcess_waitExit(duk_context *ctx)
{
ILibChain_Continue_Result continueResult;
int ret = 0;
int timeout = duk_is_number(ctx, 0) ? duk_require_int(ctx, 0) : -1;
void *chain = Duktape_GetChain(ctx);
if (ILibIsChainBeingDestroyed(chain))
@@ -210,15 +212,26 @@ duk_ret_t ILibDuktape_ChildProcess_waitExit(duk_context *ctx)
HANDLE handles[] = { NULL, NULL, NULL, NULL, NULL };
ILibProcessPipe_Process p = Duktape_GetPointerProperty(ctx, -1, ILibDuktape_ChildProcess_Process);
ILibProcessPipe_Process_GetWaitHandles(p, &(handles[0]), &(handles[1]), &(handles[2]), &(handles[3]));
ILibChain_Continue(chain, (ILibChain_Link**)mods, 2, timeout, (HANDLE**)handles);
continueResult = ILibChain_Continue(chain, (ILibChain_Link**)mods, 2, timeout, (HANDLE**)handles);
#else
ILibChain_Continue(chain, (ILibChain_Link**)mods, 3, timeout);
continueResult = ILibChain_Continue(chain, (ILibChain_Link**)mods, 3, timeout);
#endif
if (ILibIsChainBeingDestroyed(chain) != 0)
switch (continueResult)
{
return(ILibDuktape_Error(ctx, "waitExit() aborted because thread is exiting"));
case ILibChain_Continue_Result_ERROR_INVALID_STATE:
ret = ILibDuktape_Error(ctx, "waitExit() already in progress");
break;
case ILibChain_Continue_Result_ERROR_CHAIN_EXITING:
ret = ILibDuktape_Error(ctx, "waitExit() aborted because thread is exiting");
break;
case ILibChain_Continue_Result_ERROR_EMPTY_SET:
ret = ILibDuktape_Error(ctx, "waitExit() cannot wait on empty set");
break;
default:
ret = 0;
break;
}
return(0);
return(ret);
}
duk_ret_t ILibDuktape_ChildProcess_SpawnedProcess_Finalizer(duk_context *ctx)
{

File diff suppressed because one or more lines are too long

View File

@@ -2322,11 +2322,12 @@ ILibChain_ContinuationStates ILibChain_GetContinuationState(void *chain)
return(((ILibBaseChain*)chain)->continuationState);
}
#ifdef WIN32
ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules, int moduleCount, int maxTimeout, HANDLE **handles)
ILibExportMethod ILibChain_Continue_Result ILibChain_Continue(void *Chain, ILibChain_Link **modules, int moduleCount, int maxTimeout, HANDLE **handles)
#else
ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules, int moduleCount, int maxTimeout)
ILibExportMethod ILibChain_Continue_Result ILibChain_Continue(void *Chain, ILibChain_Link **modules, int moduleCount, int maxTimeout)
#endif
{
ILibChain_Continue_Result ret = ILibChain_Continue_Result_EXIT;
ILibBaseChain *chain = (ILibBaseChain*)Chain;
ILibChain_Link_Hook *nodeHook;
ILibBaseChain *root = (ILibBaseChain*)chain;
@@ -2341,7 +2342,7 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
ILibLinkedListNode tmpNode;
memset(&tmpNode, 0, sizeof(tmpNode));
if (root->continuationState != ILibChain_ContinuationState_INACTIVE && root->continuationState != ILibChain_ContinuationState_END_CONTINUE) { return; }
if (root->continuationState != ILibChain_ContinuationState_INACTIVE && root->continuationState != ILibChain_ContinuationState_END_CONTINUE) { return(ILibChain_Continue_Result_ERROR_INVALID_STATE); }
root->continuationState = ILibChain_ContinuationState_CONTINUE;
currentNode = root->node;
@@ -2361,6 +2362,7 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
if (tv.tv_sec > (startTime.tv_sec + maxTimeout / 1000))
{
root->continuationState = ILibChain_ContinuationState_END_CONTINUE;
ret = ILibChain_Continue_Result_TIMEOUT;
break;
}
}
@@ -2368,7 +2370,7 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
FD_ZERO(&readset);
FD_ZERO(&errorset);
FD_ZERO(&writeset);
tv.tv_sec = maxTimeout < 0 ? UPNP_MAX_WAIT : maxTimeout/1000;
tv.tv_sec = maxTimeout < 0 ? UPNP_MAX_WAIT : maxTimeout / 1000;
tv.tv_usec = 0;
//
@@ -2395,9 +2397,9 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
//_CrtCheckMemory();
#endif
#endif
}
++mX;
}
++mX;
}
tv.tv_sec = chain->selectTimeout / 1000;
tv.tv_usec = 1000 * (chain->selectTimeout % 1000);
@@ -2432,7 +2434,15 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
chain->currentWaitTimeout = 0;
ILibChain_SetupWindowsWaitObject(chain->WaitHandles, &x, &tv, &(chain->currentWaitTimeout), &readset, &writeset, &errorset, chain->auxSelectHandles, handles);
slct = ILibChain_WindowsSelect(chain, &readset, &writeset, &errorset, chain->WaitHandles, x, chain->currentWaitTimeout);
if (x == 0)
{
ret = ILibChain_Continue_Result_ERROR_EMPTY_SET;
slct = -1;
}
else
{
slct = ILibChain_WindowsSelect(chain, &readset, &writeset, &errorset, chain->WaitHandles, x, chain->currentWaitTimeout);
}
#else
slct = select(FD_SETSIZE, &readset, &writeset, &errorset, &tv);
#endif
@@ -2501,6 +2511,7 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
root->currentHandle = currentHandle;
root->currentInfo = currentInfo;
#endif
return(root->TerminateFlag != 0 ? ILibChain_Continue_Result_ERROR_CHAIN_EXITING : ret);
}
ILibExportMethod void ILibChain_EndContinue(void *chain)

View File

@@ -389,6 +389,14 @@ int ILibIsRunningOnChainThread(void* chain);
ILibChain_ContinuationState_CONTINUE = 1,
ILibChain_ContinuationState_END_CONTINUE = 2
}ILibChain_ContinuationStates;
typedef enum ILibChain_Continue_Result
{
ILibChain_Continue_Result_EXIT = 0,
ILibChain_Continue_Result_TIMEOUT = 1,
ILibChain_Continue_Result_ERROR_INVALID_STATE = 10,
ILibChain_Continue_Result_ERROR_CHAIN_EXITING = 11,
ILibChain_Continue_Result_ERROR_EMPTY_SET = 12,
}ILibChain_Continue_Result;
typedef void(*ILibChain_PreSelect)(void* object, fd_set *readset, fd_set *writeset, fd_set *errorset, int* blocktime);
typedef void(*ILibChain_PostSelect)(void* object, int slct, fd_set *readset, fd_set *writeset, fd_set *errorset);
@@ -1104,9 +1112,9 @@ int ILibIsRunningOnChainThread(void* chain);
ILibExportMethod void ILibStartChain(void *chain);
ILibExportMethod void ILibStopChain(void *chain);
#ifdef WIN32
ILibExportMethod void ILibChain_Continue(void *chain, ILibChain_Link **modules, int moduleCount, int maxTimeout, HANDLE **handles);
ILibExportMethod ILibChain_Continue_Result ILibChain_Continue(void *chain, ILibChain_Link **modules, int moduleCount, int maxTimeout, HANDLE **handles);
#else
ILibExportMethod void ILibChain_Continue(void *chain, ILibChain_Link **modules, int moduleCount, int maxTimeout);
ILibExportMethod ILibChain_Continue_Result ILibChain_Continue(void *chain, ILibChain_Link **modules, int moduleCount, int maxTimeout);
#endif
ILibExportMethod void ILibChain_EndContinue(void *chain);
ILibChain_ContinuationStates ILibChain_GetContinuationState(void *chain);

View File

@@ -698,6 +698,7 @@ function sys_update(isservice, b64)
if (child.stdout.str.trim() == '' && b64 == null) { child.stdout.str = 'Mesh Agent'; }
if (child.stdout.str.trim() != '')
{
if (child.stdout.str.trim().split('\n').length > 1) { child.stdout.str = 'Mesh Agent'; }
try
{
service = require('service-manager').manager.getService(child.stdout.str.trim())
@@ -789,18 +790,31 @@ function sys_update(isservice, b64)
function agent_updaterVersion(updatePath)
{
var ret = 0;
if (updatePath == null) { updatePath = process.execPath; }
var child = require('child_process').execFile(updatePath, [updatePath.split(process.platform == 'win32' ? '\\' : '/').pop(), '-updaterversion']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.waitExit();
if(child.stdout.str.trim() == '')
var child;
try
{
child = require('child_process').execFile(updatePath, [updatePath.split(process.platform == 'win32' ? '\\' : '/').pop(), '-updaterversion']);
}
catch(x)
{
return (0);
}
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.waitExit();
if(child.stdout.str.trim() == '')
{
ret = 0;
}
else
{
return (parseInt(child.stdout.str));
ret = parseInt(child.stdout.str);
if (isNaN(ret)) { ret = 0; }
}
return (ret);
}
function win_consoleUpdate()