mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-24 05:22:22 +00:00
throw on non zero exit code from workers
This commit is contained in:
parent
d4703df14d
commit
46974066a4
@ -21,6 +21,7 @@ namespace MalwareMultiScan.Backends.Backends.Abstracts
|
|||||||
protected virtual Regex MatchRegex { get; }
|
protected virtual Regex MatchRegex { get; }
|
||||||
protected virtual string BackendPath { get; }
|
protected virtual string BackendPath { get; }
|
||||||
protected virtual bool ParseStdErr { get; }
|
protected virtual bool ParseStdErr { get; }
|
||||||
|
protected virtual bool ThrowOnNonZeroExitCode { get; } = true;
|
||||||
|
|
||||||
protected virtual string GetBackendArguments(string path)
|
protected virtual string GetBackendArguments(string path)
|
||||||
{
|
{
|
||||||
@ -55,12 +56,15 @@ namespace MalwareMultiScan.Backends.Backends.Abstracts
|
|||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
|
|
||||||
_logger.LogInformation($"Process has exited with code {process.ExitCode}");
|
_logger.LogInformation($"Process has exited with code {process.ExitCode}");
|
||||||
|
|
||||||
var standardOutput = await process.StandardOutput.ReadToEndAsync();
|
var standardOutput = await process.StandardOutput.ReadToEndAsync();
|
||||||
var standardError = await process.StandardError.ReadToEndAsync();
|
var standardError = await process.StandardError.ReadToEndAsync();
|
||||||
|
|
||||||
_logger.LogDebug($"Process standard output: {standardOutput}");
|
_logger.LogDebug($"Process standard output: {standardOutput}");
|
||||||
_logger.LogDebug($"Process standard error: {standardError}");
|
_logger.LogDebug($"Process standard error: {standardError}");
|
||||||
|
|
||||||
|
if (ThrowOnNonZeroExitCode && process.ExitCode != 0)
|
||||||
|
throw new ApplicationException($"Process has terminated with an exit code {process.ExitCode}");
|
||||||
|
|
||||||
return MatchRegex
|
return MatchRegex
|
||||||
.Matches(ParseStdErr ? standardError : standardOutput)
|
.Matches(ParseStdErr ? standardError : standardOutput)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user