Do not propagate exceptions from Process.Kill() if the process actually exits (#166)

* Ignore more exceptions from Process.Kill()

Sometimes we get an InvalidOperationException when we kill a process that is already dead and other times we get a Win32Exception. Let's ignore all exceptions from killing a process if it has exited.

* Fix key name typo in README.md

The name of the key has an underscore, not a hyphen.
pull/167/head
iforapsy 2016-12-20 06:20:08 -08:00 committed by Oleg Nenashev
parent 099c41f19d
commit 28917c44d6
2 changed files with 8 additions and 2 deletions

View File

@ -90,6 +90,6 @@ New versions with fixes may be released on-demand.
### Build Environment
* IDE: [Visual Studio Community 2013](http://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx) (free for open-source projects)
* `winsw-key.snk` should be available in the project's root in order to build the executable
* `winsw_key.snk` should be available in the project's root in order to build the executable
* You can generate the certificate in "Project Settings/Signing"
* The certificate is in <code>.gitignore</code> list. Please do not add it to the repository

View File

@ -66,9 +66,15 @@ namespace winsw.Util
Logger.Warn("SIGINT to " + pid + " failed - Killing as fallback");
proc.Kill();
}
catch (ArgumentException)
catch (Exception ex)
{
if (!proc.HasExited)
{
throw;
}
// Process already exited.
Logger.Warn("Ignoring exception from killing process because it has exited", ex);
}
}