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 |
| use take::take_lines; | ||
|
|
||
| #[derive(Error, Debug)] | ||
| enum HeadError { |
There was a problem hiding this comment.
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.
Yeah, that'd be a lot more consistent. I'd definitely do that
| let mut stdout = stdout.lock(); | ||
|
|
||
| io::copy(&mut reader, &mut stdout)?; | ||
| stdout.flush()?; |
There was a problem hiding this comment.
maybe add a comment explaining why the flush is important
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:
headto use error enums instead of directly returningUErrors from USimpleError, thus allowing it to print specific errors like I/O errors (including the "device full" message when writing to /dev/full).BufWriterunderread_n_linesis deleted asstdoutalready implementsWrite. moreover, this will improve performance under specific platforms asio::copywill try to make use of platform-specific write calls that do not use user-space buffer.