Class ExecInteractiveSession
- Namespace
- OpenShell
- Assembly
- OpenShell.Sdk.dll
A running interactive command. Read ReadEventsAsync(CancellationToken) (once) for output, write stdin and resize the terminal concurrently, and await WaitForExitAsync(CancellationToken) for the exit code.
public sealed class ExecInteractiveSession : IAsyncDisposable
- Inheritance
-
ExecInteractiveSession
- Implements
- Inherited Members
Properties
ExitCode
Completes with the exit code once the command finished; faults if the stream failed first.
public Task<int> ExitCode { get; }
Property Value
Methods
CancelAsync()
Cancels the command and releases the stream.
public ValueTask CancelAsync()
Returns
CompleteStdinAsync()
Closes standard input (EOF) while output keeps flowing.
public ValueTask CompleteStdinAsync()
Returns
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
ReadEventsAsync(CancellationToken)
Streams output and finally the exit event. May be enumerated once. If the gateway closes the stream without an exit event the enumeration throws, so a failing command cannot be missed.
public IAsyncEnumerable<ExecEvent> ReadEventsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
ResizeAsync(uint, uint, CancellationToken)
Tells the command's terminal about a new window size.
public ValueTask ResizeAsync(uint columns, uint rows, CancellationToken cancellationToken = default)
Parameters
columnsuintrowsuintcancellationTokenCancellationToken
Returns
WaitForExitAsync(CancellationToken)
Waits for the exit code. When nobody is reading ReadEventsAsync(CancellationToken), output is drained and discarded.
public ValueTask<int> WaitForExitAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
WriteStdinAsync(ReadOnlyMemory<byte>, CancellationToken)
Sends bytes to the command's standard input.
public ValueTask WriteStdinAsync(ReadOnlyMemory<byte> data, CancellationToken cancellationToken = default)
Parameters
dataReadOnlyMemory<byte>cancellationTokenCancellationToken