alnyan/yggdrasil: fix start_terminal_session()
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
#![unstable(feature = "yggdrasil_os", issue = "none")]
|
#![unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
|
||||||
use yggdrasil_rt::io::{device::DeviceRequest, terminal as rt_terminal};
|
use yggdrasil_rt::io::{device::DeviceRequest, terminal as rt_terminal, FileMode, OpenOptions};
|
||||||
use yggdrasil_rt::sys as syscall;
|
use yggdrasil_rt::sys as syscall;
|
||||||
|
|
||||||
use crate::fs::File;
|
use crate::fs::File;
|
||||||
use crate::io;
|
use crate::io;
|
||||||
use crate::mem::MaybeUninit;
|
use crate::mem::MaybeUninit;
|
||||||
use crate::os::fd::{AsRawFd, FromRawFd};
|
use crate::os::fd::{AsRawFd, FromRawFd, RawFd};
|
||||||
use crate::path::Path;
|
use crate::path::Path;
|
||||||
use crate::sys::cvt_io;
|
use crate::sys::cvt_io;
|
||||||
|
|
||||||
@@ -55,19 +55,23 @@ pub unsafe fn update_terminal_options<F: AsRawFd, M: Fn(TerminalOptions) -> Term
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
pub unsafe fn start_terminal_session<P: AsRef<Path>>(_terminal: P) -> io::Result<()> {
|
pub unsafe fn start_terminal_session<P: AsRef<Path>>(terminal: P) -> io::Result<()> {
|
||||||
todo!()
|
let terminal = terminal.as_ref().to_str().unwrap();
|
||||||
// let terminal = terminal.as_ref().to_str().unwrap();
|
|
||||||
|
|
||||||
// cvt_io(syscall::start_session())?;
|
cvt_io(syscall::start_session())?;
|
||||||
|
|
||||||
// // TODO implement open flags to explicitly set stdin/stdout/stderr
|
let stdin_fd = cvt_io(syscall::open(None, terminal, OpenOptions::READ, FileMode::empty()))?;
|
||||||
|
let stdout_stderr_fd =
|
||||||
|
cvt_io(syscall::open(None, terminal, OpenOptions::WRITE, FileMode::empty()))?;
|
||||||
|
|
||||||
// cvt_io(syscall::open(None, terminal, OpenOptions::READ, FileMode::empty()))?;
|
cvt_io(syscall::clone_fd(stdin_fd, Some(RawFd::STDIN)))?;
|
||||||
// cvt_io(syscall::open(None, terminal, OpenOptions::WRITE, FileMode::empty()))?;
|
cvt_io(syscall::clone_fd(stdout_stderr_fd, Some(RawFd::STDOUT)))?;
|
||||||
// cvt_io(syscall::open(None, terminal, OpenOptions::WRITE, FileMode::empty()))?;
|
cvt_io(syscall::clone_fd(stdout_stderr_fd, Some(RawFd::STDERR)))?;
|
||||||
|
|
||||||
// Ok(())
|
cvt_io(syscall::close(stdin_fd))?;
|
||||||
|
cvt_io(syscall::close(stdout_stderr_fd))?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
|||||||
@@ -30,3 +30,11 @@ pub mod signal {
|
|||||||
unsafe { crate::sys::signal::set_signal_handler(signal, handler) }
|
unsafe { crate::sys::signal::set_signal_handler(signal, handler) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "yggdrasil_libc", issue = "none")]
|
||||||
|
pub mod libc_runtime {
|
||||||
|
#[unstable(feature = "yggdrasil_libc", issue = "none")]
|
||||||
|
pub unsafe fn start(_arg: usize) -> ! {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user