diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2010-07-05 01:31:52 +0400 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2010-07-05 01:31:52 +0400 |
commit | f79db26b02512d9b2fe071ace4de21a7cfd2cb94 (patch) | |
tree | 6e2dac8e4326e5a3948e660f5d8b3cd522fe2591 /mcs/class | |
parent | 93c6d15d753911b2600748a48c262c784f4a061e (diff) |
2010-07-04 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Process.cs: ignore processes that finish while we are looking for
processes by name. Fixes bug #596779.
svn path=/branches/mono-2-6/mcs/; revision=159867
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System/System.Diagnostics/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System/System.Diagnostics/Process.cs | 25 |
2 files changed, 21 insertions, 9 deletions
diff --git a/mcs/class/System/System.Diagnostics/ChangeLog b/mcs/class/System/System.Diagnostics/ChangeLog index 850b63a17d6..e0735f1e6c8 100644 --- a/mcs/class/System/System.Diagnostics/ChangeLog +++ b/mcs/class/System/System.Diagnostics/ChangeLog @@ -1,3 +1,8 @@ +2010-07-04 Gonzalo Paniagua Javier <gonzalo@novell.com> + + * Process.cs: ignore processes that finish while we are looking for + processes by name. Fixes bug #596779. + 2009-11-30 Sebastien Pouliot <sebastien@ximian.com> * Debug_2_1.cs: Change type to sealed to match SL2/3 diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs index 29a2b05941d..9126d85985d 100644 --- a/mcs/class/System/System.Diagnostics/Process.cs +++ b/mcs/class/System/System.Diagnostics/Process.cs @@ -889,19 +889,26 @@ namespace System.Diagnostics { public static Process[] GetProcessesByName(string processName) { - Process [] procs = GetProcesses(); - ArrayList proclist = new ArrayList(); + int [] pids = GetProcesses_internal (); + if (pids == null) + return new Process [0]; - for (int i = 0; i < procs.Length; i++) { - /* Ignore case */ - if (String.Compare (processName, - procs [i].ProcessName, - true) == 0) { - proclist.Add (procs [i]); + ArrayList proclist = new ArrayList (); + for (int i = 0; i < pids.Length; i++) { + try { + Process p = GetProcessById (pids [i]); + if (String.Compare (processName, p.ProcessName, true) == 0) + proclist.Add (p); + } catch (SystemException) { + /* The process might exit + * between + * GetProcesses_internal and + * GetProcessById + */ } } - return ((Process[]) proclist.ToArray (typeof(Process))); + return ((Process []) proclist.ToArray (typeof (Process))); } [MonoTODO] |