The wait hint when changing the service status to stopped failed to take
into account the grace period after sending a Control-C event. It also
failed to consider the case where one or more stop methods were
disabled.
/* Signal we are stopping */\r
if (graceful) {\r
service_status.dwCurrentState = SERVICE_STOP_PENDING;\r
- service_status.dwWaitHint = NSSM_KILL_WINDOW_GRACE_PERIOD + NSSM_KILL_THREADS_GRACE_PERIOD + NSSM_WAITHINT_MARGIN;\r
+ service_status.dwWaitHint = NSSM_WAITHINT_MARGIN;\r
+ if (stop_method & NSSM_STOP_METHOD_CONSOLE && imports.AttachConsole) service_status.dwWaitHint += NSSM_KILL_CONSOLE_GRACE_PERIOD;\r
+ if (stop_method & NSSM_STOP_METHOD_WINDOW) service_status.dwWaitHint += NSSM_KILL_WINDOW_GRACE_PERIOD;\r
+ if (stop_method & NSSM_STOP_METHOD_THREADS) service_status.dwWaitHint += NSSM_KILL_THREADS_GRACE_PERIOD;\r
SetServiceStatus(service_handle, &service_status);\r
}\r
\r