Treat ERROR_SERVICE_CANNOT_ACCEPT_CTRL as success for stop command

pull/387/head
NextTurn 2020-01-29 00:00:00 +08:00
parent ad329b60ca
commit da2772c6c4
No known key found for this signature in database
GPG Key ID: 17A0D50ADDE1A0C4
1 changed files with 16 additions and 1 deletions

View File

@ -728,7 +728,22 @@ namespace winsw
if (s is null)
ThrowNoSuchService();
s.StopService();
try
{
s.StopService();
}
catch (WmiException e)
{
if (e.ErrorCode == ReturnValue.ServiceCannotAcceptControl)
{
Log.Info($"The service with ID '{descriptor.Id}' is not running");
}
else
{
throw;
}
}
return;
}