Last active
April 21, 2018 16:47
-
-
Save mk-pmb/adae211e875ff11274d9b81248d033a3 to your computer and use it in GitHub Desktop.
Mono stdin strangeness, Wine bug #45039 https://bugs.winehq.org/show_bug.cgi?id=45039
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
namespace shout | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
// reopenStdin(maxLineLen: 4 * 1024); | |
string text = ask("What should I shout?"); | |
Console.WriteLine(text.ToUpper() + '!'); | |
} | |
static void reopenStdin(int maxLineLen) { | |
Stream stdin = Console.OpenStandardInput(maxLineLen); | |
Console.SetIn(new StreamReader(stdin)); | |
} | |
static string ask(string q) | |
{ | |
Console.WriteLine("D: In is a " + safeGetType(Console.In)); | |
if (Console.In is System.IO.StreamReader) | |
{ | |
Console.WriteLine("D: In also is a StreamReader"); | |
} | |
if (Console.In is System.IO.TextReader) | |
{ | |
Console.WriteLine("D: In also is a TextReader"); | |
} | |
Console.WriteLine(q); | |
return Console.In.ReadLine(); | |
} | |
static string safeGetType(object obj) | |
{ | |
if (obj == null) | |
{ | |
return "(null)"; | |
} | |
return obj.GetType().Name; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\inbox>echo hello| shout.exe 2>&1 | nl | |
1 D: In is a SyncTextReader | |
2 D: In also is a TextReader | |
3 What should I shout? | |
4 HELLO! | |
C:\inbox>shout.exe 2>&1 | nl | |
1 D: In is a SyncTextReader | |
2 D: In also is a TextReader | |
3 What should I shout? | |
hello | |
4 HELLO! | |
C:\inbox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wine --version | |
wine-3.6 | |
$ mono --version | |
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4ubuntu1.1) | |
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com | |
TLS: __thread | |
SIGSEGV: altstack | |
Notifications: epoll | |
Architecture: x86 | |
Disabled: none | |
Misc: softdebug | |
LLVM: supported, not enabled. | |
GC: sgen | |
$ lsb_release -sdc | fmt | |
Ubuntu 14.04.5 LTS trusty | |
$ uname -a | |
Linux hostname 3.13.0-142-generic #191-Ubuntu SMP Fri Feb 2 12:14:37 UTC 2018 i686 i686 i686 GNU/Linux | |
$ wine shout.exe | tee shout.log | |
D: In is a SyncTextReader | |
D: In also is a TextReader | |
What should I shout? | |
hello # <-- this is my terminal emulator's echo of what I typed | |
HELLO! | |
$ <<<hello wine shout.exe | tee shout.log | |
D: In is a SyncTextReader | |
D: In also is a TextReader | |
What should I shout? | |
HELLO! | |
$ <<<hello wine shout.exe |& tee shout.log | |
D: In is a SyncTextReader | |
D: In also is a TextReader | |
What should I shout? | |
HELLO! | |
$ cat | wine shout.exe |& tee shout.log | |
D: In is a SyncTextReader | |
D: In also is a TextReader | |
What should I shout? | |
hello # <-- this is my terminal emulator's echo of what I typed | |
HELLO! | |
# TTY input also works if just stderr is redirected: | |
$ wine shout.exe 2| tee shout.log | |
D: In is a StreamReader | |
D: In also is a StreamReader | |
D: In also is a TextReader | |
What should I shout? | |
hello # <-- this is my terminal emulator's echo of what I typed | |
HELLO! | |
# However, when using a TTY as stdin and redirecting both stdout and stderr: | |
$ wine shout.exe |& tee shout.log | |
D: In is a SyncTextReader | |
D: In also is a TextReader | |
What should I shout? | |
Unhandled Exception: | |
System.UnauthorizedAccessException: Access to the path "H:\[Unknown]" is denied. | |
at System.IO.FileStream.ReadData (System.Runtime.InteropServices.SafeHandle safeHandle, System.Byte[] buf, System.Int32 offset, System.Int32 count) [0x0002d] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.FileStream.ReadInternal (System.Byte[] dest, System.Int32 offset, System.Int32 count) [0x00026] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.FileStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x000a1] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.StreamReader.ReadBuffer () [0x000b3] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.StreamReader.ReadLine () [0x00021] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.UnexceptionalStreamReader.ReadLine () [0x00000] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.TextReader+SyncTextReader.ReadLine () [0x00000] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at (wrapper synchronized) System.IO.TextReader+SyncTextReader:ReadLine () | |
at shout.Program.ask (System.String q) [0x00051] in <e93cd1412592421990fb34e18c0f1d21>:0 | |
at shout.Program.Main () [0x00000] in <e93cd1412592421990fb34e18c0f1d21>:0 | |
[ERROR] FATAL UNHANDLED EXCEPTION: System.UnauthorizedAccessException: Access to the path "H:\[Unknown]" is denied. | |
at System.IO.FileStream.ReadData (System.Runtime.InteropServices.SafeHandle safeHandle, System.Byte[] buf, System.Int32 offset, System.Int32 count) [0x0002d] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.FileStream.ReadInternal (System.Byte[] dest, System.Int32 offset, System.Int32 count) [0x00026] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.FileStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x000a1] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.StreamReader.ReadBuffer () [0x000b3] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.StreamReader.ReadLine () [0x00021] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.UnexceptionalStreamReader.ReadLine () [0x00000] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at System.IO.TextReader+SyncTextReader.ReadLine () [0x00000] in <1c90db0b17cb4b1e827d577d0607b212>:0 | |
at (wrapper synchronized) System.IO.TextReader+SyncTextReader:ReadLine () | |
at shout.Program.ask (System.String q) [0x00051] in <e93cd1412592421990fb34e18c0f1d21>:0 | |
at shout.Program.Main () [0x00000] in <e93cd1412592421990fb34e18c0f1d21>:0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment