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
2 changes: 1 addition & 1 deletion lib/console/terminal/xterm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def colors?
# The size of the terminal.
def size
@stream.winsize
rescue Errno::ENOTTY
rescue Errno::ENOTTY, Errno::ENODEV
# Fake it...
[24, 80]
end
Expand Down
4 changes: 4 additions & 0 deletions releases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Releases

## Unreleased

- Fix handling of `Errno::ENODEV` errors when calculating the width of a terminal that was been re-opened to `File::NULL`.

## v1.34.1

- Add `process_id` to serialized output records for clarity (`pid` is still included for backwards compatibility).
Expand Down
10 changes: 10 additions & 0 deletions test/console/terminal/xterm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,15 @@
expect(stream).to receive(:winsize).and_return([24, 80])
expect(terminal.size).to be == [24, 80]
end

it "returns default size when Errno::ENOTTY is raised" do
expect(stream).to receive(:winsize).and_raise(Errno::ENOTTY)
expect(terminal.size).to be == [24, 80]
end

it "returns default size when Errno::ENODEV is raised" do
terminal = subject.new(File.open(File::NULL, "w"))
expect(terminal.size).to be == [24, 80]
end
end
end
Loading