-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Depending on whether a binary is run directly or with cargo run
, isatty()
seems to give different results. For example, given the following code:
fn main() {
let fileno = unsafe { libc::STDIN_FILENO as i32 };
let isatty = unsafe { libc::isatty(fileno) };
println!("fileno: {}, isatty: {}", fileno, isatty);
}
When run with cargo run
, the output is
fileno: 0, isatty: 0
However, when the binary is directly run, the output is
fileno: 0, isatty: 0
I'm not sure if this is expected or not, or if it's fixable from Rust rather than from the C implementation, but I thought I was worth checking just in case.
EDIT: I'm realizing this is more like caused by something in Cargo than libc, so there's probably nothing that can be done from here.
Activity
posborne commentedon Mar 26, 2016
The output appears to be the same in the sample you provided? Did you paste the wrong output for one of the two?
saghm commentedon Mar 26, 2016
Sorry, forgot to mention this only happens on the latest nightly (2016-03-24), not any earlier nightlies or on stable.
alexcrichton commentedon Mar 26, 2016
I believe this is a dupe of rust-lang/rust#32254 caused by rust-lang/rust#31618 and fixed in rust-lang/rust#32257, so closing in favor of rust-lang/rust#32254 but thanks for the report!
Fix rustfmt (rust-lang#239)