hermit-os / hermit-rs

Hermit for Rust.
Apache License 2.0
1.66k stars 86 forks source link

Question: How to input text? #618

Closed commitcompanion closed 1 week ago

commitcompanion commented 2 weeks ago

Hello,

I would like to know how to input text, process it, and output the result. Here is an attempt I made, but it doesn't seem to work correctly:

use std::io;

[cfg(target_os = "hermit")]

use hermit as _;

fn main() { let mut input = String::new();

// Reads the input from STDIN and places it in the String named input.
println!("Enter a value:");
io::stdin().read_line(&mut input).expect("Failed to read line");
print!("'{}'", input);

} Printing is straightforward, but I'm having trouble with inputting text from the keyboard in the QEMU shell. Could you please guide me on how to do this correctly?

Thank you for your help!

P.S. This is a question, and I apologize if this is not the right place to ask. Error Message: [0][WARN] Unable to read entropy! Fallback to a naive implementation! Enter a value: thread 'main' panicked at src/main.rs:11:39: Failed to read line: Kind(Uncategorized) note: run withRUST_BACKTRACE=1` environment variable to display a backtrace Number of interrupts

[0][INFO] shutting down with code -1

hello_hermit on  master [?] is 📦 v0.1.0 via 🦀 v1.83.0-nightly ❯ ` Without the input code it works verry well.