Change io crate & add a small shell
This commit is contained in:
6
user/agetty/Cargo.toml
Normal file
6
user/agetty/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "agetty"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
29
user/agetty/src/main.rs
Normal file
29
user/agetty/src/main.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
#![allow(unused)]
|
||||
#![feature(survos_std)]
|
||||
|
||||
use core::sync::atomic::AtomicUsize;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Stdin, Write, stdin, stdout};
|
||||
use std::os::fd::FromRawFd;
|
||||
|
||||
fn main() {
|
||||
// Close descriptor 0
|
||||
let f = unsafe { File::from_raw_fd(0) };
|
||||
drop(f);
|
||||
|
||||
// Close descriptor 1
|
||||
let f = unsafe { File::from_raw_fd(1) };
|
||||
drop(f);
|
||||
|
||||
// Open new input and output
|
||||
let mut input = File::open("/dev/tty0");
|
||||
let mut tty = File::open("/dev/tty0");
|
||||
|
||||
std::process::Command::new("/usr/bin/shell")
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
std::thread::yield_now();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user