Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Panic when reading from fifo or named pipe #20

Open
lilyball opened this issue May 20, 2020 · 2 comments
Open

Panic when reading from fifo or named pipe #20

lilyball opened this issue May 20, 2020 · 2 comments

Comments

@lilyball
Copy link

If I pass xxv a fifo or a named pipe (such as /dev/stdin) it promptly panics, leaving my terminal in a bad state.



Panic in xxv 0.1.2, 2020-05-20T11:03:25-07:00.
System: macos (unix), x86_64.
Location: src/hex_view.rs:397:13.

   0:        0x10628140d - backtrace::capture::Backtrace::new::ha9f89a6fa35894cc
   1:        0x10626fffb - xxv::panic_hook::install::{{closure}}::h8cc3772e827e167c
   2:        0x1062aeca4 - std::panicking::rust_panic_with_hook::he4f5d8b43533efd5
   3:        0x1062aea69 - rust_begin_unwind
   4:        0x106285e4f - core::panicking::panic_fmt::h3559129da805eab4
   5:        0x106286025 - core::result::unwrap_failed::h170de03e7ee26a1a
   6:        0x10625a28d - cursive::view::view_wrapper::<impl cursive::view::view_trait::View for T>::layout::hd14996d839b09c6c

@chrisvest
Copy link
Owner

Right... we can't fseek a pipe.

Currently things work by seeking each line in the window projected over the file. That's how XXV can navigate anywhere in arbitrarily large files.

For something like stdin, we can't navigate and new data can come along all the time. Would it be reasonable to funnel the data to a temporary file in a background thread, and then place the normal view on that file?

@lilyball
Copy link
Author

At a bare minimum, we shouldn't panic in a way that puts the terminal in a bad state. The minimal fix here is detecting that the file is a pipe and gracefully erroring.

But yes, I think a better long-term fix is to funnel the data into a temporary file and seek on that. I'd say maybe seeking on a memory buffer except then you have to deal with dumping it to disk once it gets sufficiently large, so maybe just using a temporary file always is a good idea.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants