Skip to content

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

@saghm

Description

@saghm

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

posborne commented on Mar 26, 2016

@posborne
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

saghm commented on Mar 26, 2016

@saghm
Author

Sorry, forgot to mention this only happens on the latest nightly (2016-03-24), not any earlier nightlies or on stable.

alexcrichton

alexcrichton commented on Mar 26, 2016

@alexcrichton
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!

added a commit that references this issue on Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @posborne@alexcrichton@saghm

        Issue actions

          `isatty` gives different results depending on wheter `cargo run` is used · Issue #239 · rust-lang/libc