Skip to content
Snippets Groups Projects
Commit 4ca33c11 authored by Katsu Kawakami's avatar Katsu Kawakami
Browse files

Check if stdin is from a tty

parent f8dc38c0
No related branches found
No related tags found
No related merge requests found
#[test]
fn it_works() {
#![feature(libc)]
extern crate libc;
pub fn readline() -> Option<String> {
// Buffer to hold readline input
let buffer = String::new();
let isatty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0;
if isatty {
println!("stdin is a tty");
} else {
println!("stdin is not a tty");
}
buffer
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment