The following code just runs a command:
use std::process::Command;
fn main() {
let mut command = Command::new("script");
command.arg("-qec").arg("sleep 4").arg("/dev/null");
let mut child = command.spawn().expect("failed to spawn command");
child.wait().expect("editor exited with a non-zero exit");
}
When I press Ctrl + C to interrupt the command, I see this:
^Calex@alex-M52AD-M12AD-A-F-K31AD:~/rust/ctrl-raw$
I was expecting to see a newline after ^C
:
^C
alex@alex-M52AD-M12AD-A-F-K31AD:~/rust/ctrl-raw$
Why isn't there a newline?
Note: If I execute sleep 4
directly in the terminal, I see a newline:
alex@alex-M52AD-M12AD-A-F-K31AD:~/rust/ctrl-raw$ sleep 4
^C
alex@alex-M52AD-M12AD-A-F-K31AD:~/rust/ctrl-raw$
Original post.