1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-15 15:53:55 +00:00

1. Fixed process.kill() on windows to wait to complete

2. Updated self update on windows to handle stale processes
This commit is contained in:
Bryan Roe
2020-05-20 21:10:02 -07:00
parent 79e7b74598
commit 70979ad761
4 changed files with 79 additions and 12 deletions

View File

@@ -862,12 +862,31 @@ int wmain(int argc, char* wargv[])
#endif
#ifndef _MINCORE
else if (argc > 1 && memcmp(argv[1], "-update:", 8) == 0)
{
// Attempt to copy our own exe over the original exe
while (util_CopyFile(argv[0], argv[1] + 8, FALSE) == FALSE) Sleep(5000);
{
char *update = ILibMemory_Allocate(512, 0, NULL, NULL);
int updateLen = sprintf_s(update, 512, "require('agent-installer').update();");
__try
{
agent = MeshAgent_Create(0);
agent->meshCoreCtx_embeddedScript = update;
agent->meshCoreCtx_embeddedScriptLen = updateLen;
MeshAgent_Start(agent, argc, argv);
retCode = agent->exitCode;
MeshAgent_Destroy(agent);
agent = NULL;
}
__except (ILib_WindowsExceptionFilterEx(GetExceptionCode(), GetExceptionInformation(), &winException))
{
ILib_WindowsExceptionDebugEx(&winException);
}
wmain_free(argv);
return(retCode);
// Attempt to start the updated service up again
LaunchService(serviceFile);
//// Attempt to copy our own exe over the original exe
//while (util_CopyFile(argv[0], argv[1] + 8, FALSE) == FALSE) Sleep(5000);
//// Attempt to start the updated service up again
//LaunchService(serviceFile);
}
else if (argc > 1 && (strcasecmp(argv[1], "-netinfo") == 0))
{