Browse Source

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.
iforapsy 8 năm trước cách đây
mục cha
commit
28917c44d6
2 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 1 1
      README.md
  2. 7 1
      src/Core/WinSWCore/Util/ProcessHelper.cs

+ 1 - 1
README.md

@@ -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

+ 7 - 1
src/Core/WinSWCore/Util/ProcessHelper.cs

@@ -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);
                 }
             }