Kernel: cleanup sys_exec()

We now scope everyting so desctructors get called
This commit is contained in:
Bananymous 2023-07-19 23:20:39 +03:00
parent ba9fa00947
commit 4d5b14753d
1 changed files with 62 additions and 62 deletions

View File

@ -314,6 +314,8 @@ namespace Kernel
} }
BAN::ErrorOr<long> Process::sys_exec(BAN::StringView path, const char* const* argv, const char* const* envp) BAN::ErrorOr<long> Process::sys_exec(BAN::StringView path, const char* const* argv, const char* const* envp)
{
// NOTE: We scope everything for automatic deletion
{ {
BAN::Vector<BAN::String> str_argv; BAN::Vector<BAN::String> str_argv;
for (int i = 0; argv && argv[i]; i++) for (int i = 0; argv && argv[i]; i++)
@ -355,6 +357,7 @@ namespace Kernel
ASSERT(m_threads.size() == 1); ASSERT(m_threads.size() == 1);
ASSERT(&Process::current() == this); ASSERT(&Process::current() == this);
// allocate memory on the new process for arguments and environment
{ {
LockGuard _(page_table()); LockGuard _(page_table());
@ -379,13 +382,10 @@ namespace Kernel
m_userspace_info.argc = str_argv.size(); m_userspace_info.argc = str_argv.size();
// NOTE: These must be manually cleared since this function won't return after this point asm volatile("cli");
str_argv.clear();
str_envp.clear();
CriticalScope _;
lock_guard.~LockGuard();
m_threads.front()->setup_exec(); m_threads.front()->setup_exec();
}
Scheduler::get().execute_current_thread(); Scheduler::get().execute_current_thread();
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }