Task

Demonstrate how to check whether the output device is a terminal or not.



Related task

   Check input device is a terminal


/* Uses C library interface */
 
extern crate libc;
 
fn main() {
    let istty = unsafe { libc::isatty(libc::STDOUT_FILENO as i32) } != 0;
    if istty {
        println!("stdout is tty");
    } else {
        println!("stdout is not tty");
    }
}