mirror of https://github.com/lidarr/Lidarr
Changed how running a process and waiting for exit is handled
This commit is contained in:
parent
c5a3b714e6
commit
7d4a514a68
|
@ -179,9 +179,7 @@ namespace NzbDrone.Common.Processes
|
||||||
public ProcessOutput StartAndCapture(string path, string args = null)
|
public ProcessOutput StartAndCapture(string path, string args = null)
|
||||||
{
|
{
|
||||||
var output = new ProcessOutput();
|
var output = new ProcessOutput();
|
||||||
var process = Start(path, args, s => output.Standard.Add(s), error => output.Error.Add(error));
|
Start(path, args, s => output.Standard.Add(s), error => output.Error.Add(error)).WaitForExit();
|
||||||
|
|
||||||
WaitForExit(process);
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -190,10 +188,7 @@ namespace NzbDrone.Common.Processes
|
||||||
{
|
{
|
||||||
Logger.Trace("Waiting for process {0} to exit.", process.ProcessName);
|
Logger.Trace("Waiting for process {0} to exit.", process.ProcessName);
|
||||||
|
|
||||||
if (!process.HasExited)
|
process.WaitForExit();
|
||||||
{
|
|
||||||
process.WaitForExit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPriority(int processId, ProcessPriorityClass priority)
|
public void SetPriority(int processId, ProcessPriorityClass priority)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
using NzbDrone.Common.Model;
|
using NzbDrone.Common.Model;
|
||||||
using NzbDrone.Common.Processes;
|
using NzbDrone.Common.Processes;
|
||||||
|
|
||||||
|
@ -9,10 +10,12 @@ namespace NzbDrone.Mono
|
||||||
public class NzbDroneProcessProvider : INzbDroneProcessProvider
|
public class NzbDroneProcessProvider : INzbDroneProcessProvider
|
||||||
{
|
{
|
||||||
private readonly IProcessProvider _processProvider;
|
private readonly IProcessProvider _processProvider;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public NzbDroneProcessProvider(IProcessProvider processProvider)
|
public NzbDroneProcessProvider(IProcessProvider processProvider, Logger logger)
|
||||||
{
|
{
|
||||||
_processProvider = processProvider;
|
_processProvider = processProvider;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProcessInfo> FindNzbDroneProcesses()
|
public List<ProcessInfo> FindNzbDroneProcesses()
|
||||||
|
@ -21,10 +24,19 @@ namespace NzbDrone.Mono
|
||||||
|
|
||||||
return monoProcesses.Where(c =>
|
return monoProcesses.Where(c =>
|
||||||
{
|
{
|
||||||
var processArgs = _processProvider.StartAndCapture("ps", String.Format("-p {0} -o args=", c.Id));
|
try
|
||||||
|
{
|
||||||
|
var processArgs = _processProvider.StartAndCapture("ps", String.Format("-p {0} -o args=", c.Id));
|
||||||
|
|
||||||
|
return processArgs.Standard.Any(p => p.Contains(ProcessProvider.NZB_DRONE_PROCESS_NAME + ".exe") ||
|
||||||
|
p.Contains(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME + ".exe"));
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.WarnException("Error getting process arguments", ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return processArgs.Standard.Any(p => p.Contains(ProcessProvider.NZB_DRONE_PROCESS_NAME + ".exe") ||
|
|
||||||
p.Contains(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME + ".exe"));
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue