-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
head: make head fail when writing to /dev/full #7068
Conversation
4ae10b0
to
77e734e
Compare
GNU testsuite comparison:
|
77e734e
to
4f6540c
Compare
i think android doesn't like regular users writing to /dev/full so i skipped the check for android. |
GNU testsuite comparison:
|
I think it needs to be fixed :) |
Oh yeah |
4f6540c
to
74529ec
Compare
i tried the gnu testsuite against the latest gnu coreutils (git) and it passed. could it be related to #7059 ? I actually have little idea of how the CI is run right now hehe |
now it automagically works, cool |
@@ -37,6 +36,36 @@ mod take; | |||
use take::take_all_but; | |||
use take::take_lines; | |||
|
|||
#[derive(Error, Debug)] | |||
enum HeadError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much better, thanks :)
I think we should move all the quick_error to thiserror in the code base if you are interested :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that'd be a lot more consistent. I'd definitely do that
@@ -225,6 +251,7 @@ where | |||
let mut stdout = stdout.lock(); | |||
|
|||
io::copy(&mut reader, &mut stdout)?; | |||
stdout.flush()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a comment explaining why the flush is important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
74529ec
to
509b755
Compare
GNU testsuite comparison:
|
Resolves #7029.
Head did not correctly exit when writing to /dev/full because the buffer reader is not properly flushed after the copy operation. This PR addresses the latter.
Changes introduced alongside:
head
to use error enums instead of directly returningUError
s from USimpleError, thus allowing it to print specific errors like I/O errors (including the "device full" message when writing to /dev/full).BufWriter
underread_n_lines
is deleted asstdout
already implementsWrite
. moreover, this will improve performance under specific platforms asio::copy
will try to make use of platform-specific write calls that do not use user-space buffer.