Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ protected override void EndProcessing()
// need null terminator at end
execArgs[execArgs.Length - 1] = null;

// setup termios for a child process as .NET modifies termios dynamically for use with ReadKey()
ConfigureTerminalForChildProcess(true);
int exitCode = Exec(command.Source, execArgs);

if (exitCode < 0)
{
ConfigureTerminalForChildProcess(false);
ThrowTerminatingError(
new ErrorRecord(
new Exception(
Expand Down Expand Up @@ -108,6 +110,10 @@ protected override void EndProcessing()
CharSet = CharSet.Ansi,
SetLastError = true)]
private static extern int Exec(string path, string?[] args);

// leverage .NET runtime's native library which abstracts the need to handle different OS and architectures for termios api
[DllImport("libSystem.Native", EntryPoint = "SystemNative_ConfigureTerminalForChildProcess")]
private static extern void ConfigureTerminalForChildProcess([MarshalAs(UnmanagedType.Bool)] bool childUsesTerminal);
}
}

Expand Down