mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Remove unneeded SSH standard handle workaround (#15308)
This commit is contained in:
@@ -525,27 +525,16 @@ namespace System.Management.Automation.Remoting.Server
|
||||
|
||||
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
|
||||
|
||||
@@ -688,24 +688,6 @@ namespace System.Management.Automation
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user