diff --git a/NzbDrone.Common.Test/ProcessProviderTests.cs b/NzbDrone.Common.Test/ProcessProviderTests.cs index a5b2d0b1b..1978203a3 100644 --- a/NzbDrone.Common.Test/ProcessProviderTests.cs +++ b/NzbDrone.Common.Test/ProcessProviderTests.cs @@ -68,8 +68,6 @@ public void Should_be_able_to_start_process() Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should().BeFalse(); } - - [Test] public void Should_be_able_to_execute_process() { diff --git a/NzbDrone.Common/ProcessProvider.cs b/NzbDrone.Common/ProcessProvider.cs index fd11e1bce..ec3df0672 100644 --- a/NzbDrone.Common/ProcessProvider.cs +++ b/NzbDrone.Common/ProcessProvider.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; @@ -30,6 +31,14 @@ public class ProcessProvider : IProcessProvider public const string NzbDroneProcessName = "NzbDrone"; public const string NzbDroneConsoleProcessName = "NzbDrone.Console"; + private static List GetProcessesByName(string name) + { + var monoProcesses = Process.GetProcessesByName("mono") + .Where(process => process.Modules.Cast().Any(module => module.ModuleName.ToLower() == name + ".exe")); + return Process.GetProcessesByName(name) + .Union(monoProcesses).ToList(); + } + public ProcessInfo GetCurrentProcess() { return ConvertToProcessInfo(Process.GetCurrentProcess()); @@ -37,7 +46,7 @@ public ProcessInfo GetCurrentProcess() public bool Exists(string processName) { - return Process.GetProcessesByName(processName).Any(); + return GetProcessesByName(processName).Any(); } public ProcessPriorityClass GetCurrentProcessPriority() @@ -63,18 +72,6 @@ public ProcessInfo GetProcessById(int id) return processInfo; } - /* public IEnumerable GetProcessByName(string name) - { - if (OsInfo.IsMono) - { - var mono = Process.GetProcessesByName("mono"); - - return mono.Where(process => process.Modules.Cast().Any(module => module.ModuleName.ToLower() == name + ".exe")) - .Select(ConvertToProcessInfo); - } - - return Process.GetProcessesByName(name).Select(ConvertToProcessInfo).Where(p => p != null); - }*/ public Process Start(string path) { @@ -177,7 +174,7 @@ public void SetPriority(int processId, ProcessPriorityClass priority) public void KillAll(string processName) { - var processToKill = Process.GetProcessesByName(processName); + var processToKill = GetProcessesByName(processName); foreach (var processInfo in processToKill) {