3using System.Threading.Tasks;
5using Microsoft.Extensions.Logging;
31 readonly ILogger<PosixProcessFeatures>
logger;
43 this.logger =
logger ??
throw new ArgumentNullException(nameof(
logger));
49 var result = Syscall.kill(process.Id, Signum.SIGCONT);
51 throw new UnixIOException(Stdlib.GetLastError());
57 var result = Syscall.kill(process.Id, Signum.SIGSTOP);
59 throw new UnixIOException(Stdlib.GetLastError());
63 public Task<string>
GetExecutingUsername(global::System.Diagnostics.Process process, CancellationToken cancellationToken)
64 =>
throw new NotSupportedException();
67 public async Task
CreateDump(global::System.Diagnostics.Process process,
string outputFile, CancellationToken cancellationToken)
69 ArgumentNullException.ThrowIfNull(process);
70 ArgumentNullException.ThrowIfNull(outputFile);
72 const string GCorePath =
"/usr/bin/gcore";
79 if (process.HasExited)
84 catch (InvalidOperationException ex)
93 Environment.CurrentDirectory,
94 $
"-o {outputFile} {process.Id}",
95 readStandardHandles:
true,
96 noShellExecute:
true))
98 using (cancellationToken.Register(() => gcoreProc.Terminate()))
99 exitCode = await gcoreProc.Lifetime;
101 output = await gcoreProc.GetCombinedOutput(cancellationToken);
102 logger.LogDebug(
"gcore output:{0}{1}", Environment.NewLine, output);
109 $
"Exit Code: {exitCode}{Environment.NewLine}Output:{Environment.NewLine}{output}"));
112 var generatedGCoreFile = $
"{outputFile}.{pid}";
Operation exceptions thrown from the context of a Models.Job.
Task< string > GetExecutingUsername(global::System.Diagnostics.Process process, CancellationToken cancellationToken)
Get the name of the user executing a given process . The name of the user executing process .
void SuspendProcess(global::System.Diagnostics.Process process)
Suspend a given process .
readonly IIOManager ioManager
The IIOManager for the PosixProcessFeatures.
readonly Lazy< IProcessExecutor > lazyLoadedProcessExecutor
Lazy<T> loaded IProcessExecutor.
void ResumeProcess(global::System.Diagnostics.Process process)
Resume a given suspended Process.
PosixProcessFeatures(Lazy< IProcessExecutor > lazyLoadedProcessExecutor, IIOManager ioManager, ILogger< PosixProcessFeatures > logger)
Initializes a new instance of the PosixProcessFeatures class.
readonly ILogger< PosixProcessFeatures > logger
The ILogger<TCategoryName> for the PosixProcessFeatures.
async Task CreateDump(global::System.Diagnostics.Process process, string outputFile, CancellationToken cancellationToken)
Create a dump file for a given process . A Task representing the running operation.
Interface for using filesystems.
Task MoveFile(string source, string destination, CancellationToken cancellationToken)
Moves a file at source to destination .
Task< bool > FileExists(string path, CancellationToken cancellationToken)
Check that the file at path exists.
Abstraction for suspending and resuming processes.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.