-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thread panic - broken pipe when piping output to pager #15
Comments
Just tested a little further. I suspected this is was because
Using a longer output:
|
I was just about to open an issue for precisely this. Would be great to have |
Happy to look into this if you can provide a test case. Without a way to
reproduce there’s not much I can do.
…On Wed, Feb 10, 2021 at 9:44 AM Charles Strahan ***@***.***> wrote:
I was just about to open an issue for precisely this. Would be great to
have as-tree gracefully exit in this scenario.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#15 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKJUVE2DL7PC3GILZZZCJTS6LAYRANCNFSM4XJQIJSA>
.
|
@jez assuming your terminal height is less than 10,000 characters (quite probable 😅), this should do the trick:
then press |
@cstrahan awesome, thanks for the concise reproducer. I see
when i run it, which looks like the above. |
If you want a reproducer that doesn't depend on a tty: This uses a sleep so that the "a" char is piped into
If you have process at the end of your pipeline that consumes all of
The problem with using a pager (right now) is that it won't necessary consume all of its stdin (e.g. |
You can remove the
|
FWIW, looks like this is how
|
Similar to how Err(e) if e.kind() == ErrorKind::BrokenPipe => {
warn!("Broken pipe error: {}", e);
exit(exits::SUCCESS);
} |
Make sure that broken pipes (e.g. when a reader of a pipe prematurely exits during execution) get handled gracefully. This change also moves some error messages to stderr by using eprintln. More info: jez/as-tree#15
Make sure that broken pipes (e.g. when a reader of a pipe prematurely exits during execution) get handled gracefully. This change also moves some error messages to stderr by using eprintln. More info: jez/as-tree#15
To reproduce, any of these commands cause a thread panic when piping the output of
as-tree
to a pager (tested withless
,more
,most
,bat
):ls /usr/lib | as-tree | less
(same when replacingless
withmore
,most
,bat
, etc)fd | as-tree | bat
fd | as-tree | cat | less
With RUST_BACKTRACE=1, the trace output is:
The text was updated successfully, but these errors were encountered: