Fix SendWithPingUtilityAsync to catch InvalidOperationException (dotnet/corefx#35992)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Tue, 12 Mar 2019 19:16:12 +0000 (12:16 -0700)
committerGitHub <noreply@github.com>
Tue, 12 Mar 2019 19:16:12 +0000 (12:16 -0700)
* ignore InvalidOperationException from Kill

* ignore InvalidOperationException from Kill

Commit migrated from https://github.com/dotnet/corefx/commit/0f7a0bd5fb4892c1434e263824d394ab621a1b2a

src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Unix.cs

index 6da5928..3a4e3ca 100644 (file)
@@ -328,12 +328,13 @@ namespace System.Net.NetworkInformation
                 if (finished == timeoutTask && !p.HasExited)
                 {
                     // Try to kill the ping process if it didn't return. If it is already in the process of exiting, 
-                    // a Win32Exception will be thrown.
+                    // a Win32Exception will be thrown or we will get InvalidOperationException if it already exited.
                     try
                     {
                         p.Kill();
                     }
                     catch (Win32Exception) { }
+                    catch (InvalidOperationException) { }
                     return CreateTimedOutPingReply();
                 }
                 else