-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
tac: should fail when stdin is closed but doesn't #2873
Comments
Libstd opens stdin, stdout and stderr as |
The stdlib could open |
I came across this because one of the tests from I tried this, but it didn't work and I don't know why: fn get_errno() -> i32 {
Error::last_os_error().raw_os_error().unwrap()
}
pub fn stdin_is_bad_fd() -> bool {
let fd = stdin().as_raw_fd();
// FIXME: this is never `true`, even with `<&-`
unsafe { libc::fcntl(fd, libc::F_GETFD) == -1 && get_errno() == libc::EBADF }
} |
@jhscheer It's because of what @bjorn3 wrote in #2873 (comment) |
Thanks. There's a discussion about why stdlib is reopening the file descriptors here. So I guess, unless stdlib implements a better workaround than the one currently used, it's not likely we will ever pass the GNU tests mentioned above. |
Ah so in the linked PR, rust-lang/rust#75295 (comment) suggests using pipes to accomplish something similar to my suggestion in #2873 (comment). But RFC 1014 explicitly conflicts with that, as pointed out in rust-lang/rust#75295 (comment). So we can't do that unless we're okay with reverting that RFC I guess. I didn't open an issue, but there's already one: rust-lang/rust#88825 |
This is WIP or even WONT-FIX because there's a workaround in Rust's stdlib which prevents us from detecting a closed FD. see also the discussion at: uutils#2873
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Optimize tail plateform module using the libc::stdin fd constant. Commenting out `is_bad_symlink` as uutils#2873 will not be fixed for the time being.
Rework tail plateform module to tackle #2873
The
uutils
version oftac
disagrees with GNUtac
in the case wherestdin
is closed on the command line:GNU prints an error message to
stderr
and returns exit status code 1:<&-
means close stdin.uutils
prints nothing and returns exit status code 0:Edit: This causes a failure in the GNU test file
tests/tac/tac-2-nonseekable.sh
.The text was updated successfully, but these errors were encountered: