Skip to content

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

Closed
@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.

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

    Issue actions