Skip to content
Merged
Show file tree
Hide file tree
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 @@ -525,27 +525,16 @@ internal sealed class SSHProcessMediator : OutOfProcessMediatorBase

private SSHProcessMediator() : base(true)
{
#if !UNIX
var inputHandle = PlatformInvokes.GetStdHandle((uint)PlatformInvokes.StandardHandleId.Input);
originalStdIn = new StreamReader(
new FileStream(new SafeFileHandle(inputHandle, false), FileAccess.Read));

var outputHandle = PlatformInvokes.GetStdHandle((uint)PlatformInvokes.StandardHandleId.Output);
originalStdOut = new OutOfProcessTextWriter(
new StreamWriter(
new FileStream(new SafeFileHandle(outputHandle, false), FileAccess.Write)));

var errorHandle = PlatformInvokes.GetStdHandle((uint)PlatformInvokes.StandardHandleId.Error);
originalStdErr = new OutOfProcessTextWriter(
new StreamWriter(
new FileStream(new SafeFileHandle(errorHandle, false), FileAccess.Write)));
#else
originalStdIn = new StreamReader(Console.OpenStandardInput(), true);
originalStdOut = new OutOfProcessTextWriter(
new StreamWriter(Console.OpenStandardOutput()));
originalStdErr = new OutOfProcessTextWriter(
new StreamWriter(Console.OpenStandardError()));
#endif

// Disable console from writing to the PSRP streams.
Console.SetIn(TextReader.Null);
Console.SetOut(TextWriter.Null);
Console.SetError(TextWriter.Null);
}

#endregion
Expand Down
18 changes: 0 additions & 18 deletions src/System.Management.Automation/utils/PlatformInvokes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -688,24 +688,6 @@ public static extern System.IntPtr CreateFileW(
UInt32 dwFlagsAndAttributes,
System.IntPtr hTemplateFile);

#endif

#endregion

#region GetStdHandle

#if !UNIX

internal enum StandardHandleId : uint
{
Error = unchecked((uint)-12),
Output = unchecked((uint)-11),
Input = unchecked((uint)-10),
}

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr GetStdHandle(uint handleId);

#endif

#endregion
Expand Down