forked from Bananymous/banan-os
Kernel: cleanup sys_exec()
We now scope everyting so desctructors get called
This commit is contained in:
parent
ba9fa00947
commit
4d5b14753d
|
@ -314,6 +314,8 @@ namespace Kernel
|
|||
}
|
||||
|
||||
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;
|
||||
for (int i = 0; argv && argv[i]; i++)
|
||||
|
@ -355,6 +357,7 @@ namespace Kernel
|
|||
ASSERT(m_threads.size() == 1);
|
||||
ASSERT(&Process::current() == this);
|
||||
|
||||
// allocate memory on the new process for arguments and environment
|
||||
{
|
||||
LockGuard _(page_table());
|
||||
|
||||
|
@ -379,13 +382,10 @@ namespace Kernel
|
|||
|
||||
m_userspace_info.argc = str_argv.size();
|
||||
|
||||
// NOTE: These must be manually cleared since this function won't return after this point
|
||||
str_argv.clear();
|
||||
str_envp.clear();
|
||||
|
||||
CriticalScope _;
|
||||
lock_guard.~LockGuard();
|
||||
asm volatile("cli");
|
||||
m_threads.front()->setup_exec();
|
||||
}
|
||||
|
||||
Scheduler::get().execute_current_thread();
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue