Commit 5a3bae9e authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Catch another ignorable errno in setting `stdin.lineMode` (#7563)

parent 61760f63
...@@ -215,6 +215,14 @@ class AnsiTerminal { ...@@ -215,6 +215,14 @@ class AnsiTerminal {
static const String _clear = '\u001B[2J\u001B[H'; static const String _clear = '\u001B[2J\u001B[H';
static const int _ENOTTY = 25; static const int _ENOTTY = 25;
static const int _ENETRESET = 102;
/// Setting the line mode can throw for some terminals (with "Operation not
/// supported on socket"), but the error can be safely ignored.
static const List<int> _lineModeIgnorableErrors = const <int>[
_ENOTTY,
_ENETRESET,
];
bool supportsColor; bool supportsColor;
...@@ -231,8 +239,7 @@ class AnsiTerminal { ...@@ -231,8 +239,7 @@ class AnsiTerminal {
// introduced). Doing so will allow proper dereferencing of `osError`. // introduced). Doing so will allow proper dereferencing of `osError`.
bool ignore = false; bool ignore = false;
try { try {
if (error.osError?.errorCode == _ENOTTY) { if (_lineModeIgnorableErrors.contains(error.osError?.errorCode)) {
// This can throw for some terminals; we ignore the error.
ignore = true; ignore = true;
} }
} on NoSuchMethodError {} } on NoSuchMethodError {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment