WL#4189 NO need to retry OpenEvent if the process does not exist anymore
This commit is contained in:
parent
160e13cb4c
commit
fc6a7def0b
@ -49,12 +49,25 @@ int main(int argc, const char** argv )
|
|||||||
while ((shutdown_event=
|
while ((shutdown_event=
|
||||||
OpenEvent(EVENT_MODIFY_STATE, FALSE, safe_process_name)) == NULL)
|
OpenEvent(EVENT_MODIFY_STATE, FALSE, safe_process_name)) == NULL)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Check if the process is alive, otherwise there is really
|
||||||
|
no idea to retry the open of the event
|
||||||
|
*/
|
||||||
|
HANDLE process;
|
||||||
|
if ((process= OpenProcess(SYNCHRONIZE, FALSE, pid)) == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Could not open event or process %d, error: %d\n",
|
||||||
|
pid, GetLastError());
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
CloseHandle(process);
|
||||||
|
|
||||||
if (retry_open_event--)
|
if (retry_open_event--)
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open shutdown_event '%s', error: %d\n",
|
fprintf(stderr, "Failed to open shutdown_event '%s', error: %d\n",
|
||||||
safe_process_name, GetLastError());
|
safe_process_name, GetLastError());
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user