Skip to content
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

isatty gives different results depending on wheter cargo run is used #239

Closed
saghm opened this issue Mar 26, 2016 · 3 comments
Closed

isatty gives different results depending on wheter cargo run is used #239

saghm opened this issue Mar 26, 2016 · 3 comments

Comments

@saghm
Copy link

saghm commented Mar 26, 2016

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.

@posborne
Copy link
Contributor

The output appears to be the same in the sample you provided? Did you paste the wrong output for one of the two?

@saghm
Copy link
Author

saghm commented 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
Copy link
Member

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!

danielverkamp pushed a commit to danielverkamp/libc that referenced this issue Apr 28, 2020
* [fmt] manually fix some formatting
* [fmt] reformat with rustfmt-nightly
* [clippy] fix clippy issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants