Sometimes GetProcessTimes() will succeed but return 0 for the process
exit time, leading check_parent() to conclude that the service had
exited before a child process had started, and thus that the child
process was not part of the service's tree.
We now use initialise the service exit time to the current time before
attempting to get the real exit time, and only override the value if
it's valid.
Thanks Czenda Czendov.
+ if (! (exit_time.dwLowDateTime || exit_time.dwHighDateTime)) return 2;
memmove(ft, &exit_time, sizeof(exit_time));
return 0;
memmove(ft, &exit_time, sizeof(exit_time));
return 0;
\r
service->rotate_stdout_online = service->rotate_stderr_online = NSSM_ROTATE_OFFLINE;\r
\r
\r
service->rotate_stdout_online = service->rotate_stderr_online = NSSM_ROTATE_OFFLINE;\r
\r
+ /* Use now as a dummy exit time. */\r
+ GetSystemTimeAsFileTime(&service->exit_time);\r
+\r
/* Check exit code */\r
unsigned long exitcode = 0;\r
TCHAR code[16];\r
if (service->process_handle) {\r
GetExitCodeProcess(service->process_handle, &exitcode);\r
/* Check exit code */\r
unsigned long exitcode = 0;\r
TCHAR code[16];\r
if (service->process_handle) {\r
GetExitCodeProcess(service->process_handle, &exitcode);\r
- if (exitcode == STILL_ACTIVE || get_process_exit_time(service->process_handle, &service->exit_time)) GetSystemTimeAsFileTime(&service->exit_time);\r
+ /* Check real exit time. */\r
+ if (exitcode != STILL_ACTIVE) get_process_exit_time(service->process_handle, &service->exit_time);\r
CloseHandle(service->process_handle);\r
}\r
CloseHandle(service->process_handle);\r
}\r
- else GetSystemTimeAsFileTime(&service->exit_time);\r
\r
service->process_handle = 0;\r
\r
\r
service->process_handle = 0;\r
\r