forked from tgstation/tgstation-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIProcess.cs
45 lines (40 loc) · 1.64 KB
/
IProcess.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Tgstation.Server.Host.System
{
/// <summary>
/// Abstraction over a <see cref="global::System.Diagnostics.Process"/>.
/// </summary>
public interface IProcess : IProcessBase, IAsyncDisposable
{
/// <summary>
/// The <see cref="IProcess"/>' ID.
/// </summary>
int Id { get; }
/// <summary>
/// The <see cref="Task"/> representing the time until the <see cref="IProcess"/> becomes "idle".
/// </summary>
Task Startup { get; }
/// <summary>
/// Get the stderr and stdout output of the <see cref="IProcess"/>.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the stderr and stdout output of the <see cref="IProcess"/>.</returns>
/// <remarks>
/// To guarantee that all data is received from the <see cref="IProcess"/> when redirecting streams to a file
/// the result of this function must be <see langword="await"/>ed before <see cref="IAsyncDisposable.DisposeAsync"/> is called.
/// </remarks>
Task<string?> GetCombinedOutput(CancellationToken cancellationToken);
/// <summary>
/// Asycnhronously terminates the process.
/// </summary>
/// <remarks>To ensure the <see cref="IProcess"/> has ended, use the <see cref="IProcessBase.Lifetime"/> <see cref="Task{TResult}"/>.</remarks>
void Terminate();
/// <summary>
/// Get the name of the account executing the <see cref="IProcess"/>.
/// </summary>
/// <returns>The name of the account executing the <see cref="IProcess"/>.</returns>
string GetExecutingUsername();
}
}