forked from Bananymous/banan-os
Kernel: Add tty to process and make termios modifiable
This commit is contained in:
@@ -18,15 +18,10 @@ namespace Kernel
|
||||
return process;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> Process::init_stdio()
|
||||
{
|
||||
if (!m_open_files.empty())
|
||||
return BAN::Error::from_c_string("Could not init stdio, process already has open files");
|
||||
TRY(open("/dev/tty1", O_RDONLY)); // stdin
|
||||
TRY(open("/dev/tty1", O_WRONLY)); // stdout
|
||||
TRY(open("/dev/tty1", O_WRONLY)); // stderr
|
||||
return {};
|
||||
}
|
||||
Process::Process(pid_t pid)
|
||||
: m_pid(pid)
|
||||
, m_tty(TTY::current())
|
||||
{ }
|
||||
|
||||
BAN::ErrorOr<void> Process::add_thread(entry_t entry, void* data)
|
||||
{
|
||||
@@ -51,6 +46,24 @@ namespace Kernel
|
||||
m_threads.remove(i);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> Process::init_stdio()
|
||||
{
|
||||
if (!m_open_files.empty())
|
||||
return BAN::Error::from_c_string("Could not init stdio, process already has open files");
|
||||
TRY(open("/dev/tty1", O_RDONLY)); // stdin
|
||||
TRY(open("/dev/tty1", O_WRONLY)); // stdout
|
||||
TRY(open("/dev/tty1", O_WRONLY)); // stderr
|
||||
return {};
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> Process::set_termios(const termios& termios)
|
||||
{
|
||||
if (m_tty == nullptr)
|
||||
return BAN::Error::from_errno(ENOTTY);
|
||||
m_tty->set_termios(termios);
|
||||
return {};
|
||||
}
|
||||
|
||||
BAN::ErrorOr<int> Process::open(BAN::StringView path, int flags)
|
||||
{
|
||||
if (flags & ~O_RDWR)
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace Kernel
|
||||
);
|
||||
}
|
||||
|
||||
TTY* TTY::current()
|
||||
{
|
||||
return s_tty;
|
||||
}
|
||||
|
||||
void TTY::on_key(Input::KeyEvent event)
|
||||
{
|
||||
ASSERT(!m_lock.is_locked());
|
||||
|
||||
Reference in New Issue
Block a user