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>2016-11-09 16:00:11 +0300
committerGitHub <noreply@github.com>2016-11-09 16:00:11 +0300
commitd2ad946be65be041c538d6cbc0769d1ee526f92f (patch)
tree4fa694854e8f13377efd22ea1280c7767252a2b1 /mcs/class/System/System.Diagnostics
parentf96f13505ae779628623a229e2cdd7542947f37c (diff)
[process] Allocate a handle even for non-child processes (#3905)
* [w32handle] Inline only use of mono_w32handle_search * [w32handle] Make special_wait return MonoW32HandleWaitRet This is to avoid a unnecessary translation from WAIT_* to MonoW32HandleWaitRet * [process] Use some more referencesource * [process] Rename mono_processes to processes * [process] Allocate a handle even for non-child processes * [process] Create the handle only once the process has started
Diffstat (limited to 'mcs/class/System/System.Diagnostics')
-rw-r--r--mcs/class/System/System.Diagnostics/Process.cs55
1 files changed, 8 insertions, 47 deletions
diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs
index 455d60b0d22..74f1990f516 100644
--- a/mcs/class/System/System.Diagnostics/Process.cs
+++ b/mcs/class/System/System.Diagnostics/Process.cs
@@ -469,16 +469,6 @@ namespace System.Diagnostics
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static IntPtr GetProcess_internal(int pid);
- public static Process GetProcessById(int processId)
- {
- IntPtr proc = GetProcess_internal(processId);
-
- if (proc == IntPtr.Zero)
- throw new ArgumentException ("Can't find process with ID " + processId.ToString ());
-
- return (new Process (new SafeProcessHandle (proc, false), processId));
- }
-
[MonoTODO ("There is no support for retrieving process information from a remote machine")]
public static Process GetProcessById(int processId, string machineName) {
if (machineName == null)
@@ -487,34 +477,17 @@ namespace System.Diagnostics
if (!IsLocalMachine (machineName))
throw new NotImplementedException ();
- return GetProcessById (processId);
+ IntPtr proc = GetProcess_internal(processId);
+
+ if (proc == IntPtr.Zero)
+ throw new ArgumentException ("Can't find process with ID " + processId.ToString ());
+
+ return (new Process (new SafeProcessHandle (proc, false), processId));
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static int[] GetProcesses_internal();
- public static Process[] GetProcesses ()
- {
- int [] pids = GetProcesses_internal ();
- if (pids == null)
- return new Process [0];
-
- var proclist = new List<Process> (pids.Length);
- for (int i = 0; i < pids.Length; i++) {
- try {
- proclist.Add (GetProcessById (pids [i]));
- } catch (SystemException) {
- /* The process might exit
- * between
- * GetProcesses_internal and
- * GetProcessById
- */
- }
- }
-
- return proclist.ToArray ();
- }
-
[MonoTODO ("There is no support for retrieving process information from a remote machine")]
public static Process[] GetProcesses(string machineName) {
if (machineName == null)
@@ -523,21 +496,14 @@ namespace System.Diagnostics
if (!IsLocalMachine (machineName))
throw new NotImplementedException ();
- return GetProcesses ();
- }
-
- public static Process[] GetProcessesByName(string processName)
- {
int [] pids = GetProcesses_internal ();
if (pids == null)
return new Process [0];
-
+
var proclist = new List<Process> (pids.Length);
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);
+ proclist.Add (GetProcessById (pids [i]));
} catch (SystemException) {
/* The process might exit
* between
@@ -550,11 +516,6 @@ namespace System.Diagnostics
return proclist.ToArray ();
}
- [MonoTODO]
- public static Process[] GetProcessesByName(string processName, string machineName) {
- throw new NotImplementedException();
- }
-
private static bool IsLocalMachine (string machineName)
{
if (machineName == "." || machineName.Length == 0)