Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Henry <ludovic@xamarin.com>2017-02-09 06:29:03 +0300
committerGitHub <noreply@github.com>2017-02-09 06:29:03 +0300
commit41fced547f724e3eb19a7e4c6ac88b14e702e82c (patch)
tree6b0960d0ef80be1034e47ecc888d6c2d6f218379 /mcs/class/System/Test
parent9780c4d801a7670aa2243e7bd709659996d2147f (diff)
[process] Fix Process.GetProcessesByName (#4351)
To get a process by name, we need to access the other process ProcessName, but it can fails on non-win32 platforms. This failure wouldn't be caught in the referencesource implementation trigerring this bug. The exception we would observe would be: Unhandled Exception: System.InvalidOperationException: Process has exited, so the requested information is not available. at System.Diagnostics.Process.get_ProcessName () [0x0002d] in /Users/alexander/dev/mono/mcs/class/System/System.Diagnostics/Process.cs:336 at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ProcessName () at Program.Main (System.String[] args) [0x0003b] in <9c838a66cdc44c81b38c974edcc9c029>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Process has exited, so the requested information is not available. at System.Diagnostics.Process.get_ProcessName () [0x0002d] in /Users/alexander/dev/mono/mcs/class/System/System.Diagnostics/Process.cs:336 at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ProcessName () at Program.Main (System.String[] args) [0x0003b] in <9c838a66cdc44c81b38c974edcc9c029>:0 Fixes bug https://bugzilla.xamarin.com/show_bug.cgi?id=52345
Diffstat (limited to 'mcs/class/System/Test')
-rw-r--r--mcs/class/System/Test/System.Diagnostics/ProcessTest.cs7
1 files changed, 7 insertions, 0 deletions
diff --git a/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs b/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
index 20a93a732b6..ac07fdc8bab 100644
--- a/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
+++ b/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
@@ -1113,5 +1113,12 @@ namespace MonoTests.System.Diagnostics
}
}
#endif // MONO_FEATURE_PROCESS_START
+
+ [Test]
+ public void GetProcessesByName()
+ {
+ // This should return Process[0] or a Process[] with all the "foo" programs running
+ Process.GetProcessesByName ("foo");
+ }
}
}