mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 13:01:28 +02:00
GetProcessesByName for mono
This commit is contained in:
@@ -68,8 +68,6 @@ namespace NzbDrone.Common.Test
|
|||||||
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should().BeFalse();
|
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Should_be_able_to_execute_process()
|
public void Should_be_able_to_execute_process()
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -30,6 +31,14 @@ namespace NzbDrone.Common
|
|||||||
public const string NzbDroneProcessName = "NzbDrone";
|
public const string NzbDroneProcessName = "NzbDrone";
|
||||||
public const string NzbDroneConsoleProcessName = "NzbDrone.Console";
|
public const string NzbDroneConsoleProcessName = "NzbDrone.Console";
|
||||||
|
|
||||||
|
private static List<Process> GetProcessesByName(string name)
|
||||||
|
{
|
||||||
|
var monoProcesses = Process.GetProcessesByName("mono")
|
||||||
|
.Where(process => process.Modules.Cast<ProcessModule>().Any(module => module.ModuleName.ToLower() == name + ".exe"));
|
||||||
|
return Process.GetProcessesByName(name)
|
||||||
|
.Union(monoProcesses).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public ProcessInfo GetCurrentProcess()
|
public ProcessInfo GetCurrentProcess()
|
||||||
{
|
{
|
||||||
return ConvertToProcessInfo(Process.GetCurrentProcess());
|
return ConvertToProcessInfo(Process.GetCurrentProcess());
|
||||||
@@ -37,7 +46,7 @@ namespace NzbDrone.Common
|
|||||||
|
|
||||||
public bool Exists(string processName)
|
public bool Exists(string processName)
|
||||||
{
|
{
|
||||||
return Process.GetProcessesByName(processName).Any();
|
return GetProcessesByName(processName).Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProcessPriorityClass GetCurrentProcessPriority()
|
public ProcessPriorityClass GetCurrentProcessPriority()
|
||||||
@@ -63,18 +72,6 @@ namespace NzbDrone.Common
|
|||||||
return processInfo;
|
return processInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public IEnumerable<ProcessInfo> GetProcessByName(string name)
|
|
||||||
{
|
|
||||||
if (OsInfo.IsMono)
|
|
||||||
{
|
|
||||||
var mono = Process.GetProcessesByName("mono");
|
|
||||||
|
|
||||||
return mono.Where(process => process.Modules.Cast<ProcessModule>().Any(module => module.ModuleName.ToLower() == name + ".exe"))
|
|
||||||
.Select(ConvertToProcessInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Process.GetProcessesByName(name).Select(ConvertToProcessInfo).Where(p => p != null);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public Process Start(string path)
|
public Process Start(string path)
|
||||||
{
|
{
|
||||||
@@ -177,7 +174,7 @@ namespace NzbDrone.Common
|
|||||||
|
|
||||||
public void KillAll(string processName)
|
public void KillAll(string processName)
|
||||||
{
|
{
|
||||||
var processToKill = Process.GetProcessesByName(processName);
|
var processToKill = GetProcessesByName(processName);
|
||||||
|
|
||||||
foreach (var processInfo in processToKill)
|
foreach (var processInfo in processToKill)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user