fix: continue fix page fault heap regression
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#pragma once
|
||||
#include <Sched/Scheduler.hpp>
|
||||
#include <Timekeeping/ApicTimer.hpp>
|
||||
#include <Memory/Paging.hpp>
|
||||
#include <Memory/PageFrameAllocator.hpp>
|
||||
#include <Memory/HHDM.hpp>
|
||||
|
||||
#include "Syscall.hpp"
|
||||
#include "WinServer.hpp"
|
||||
@@ -105,9 +108,34 @@ namespace Zenith {
|
||||
auto* proc = Sched::GetProcessByPid(pid);
|
||||
if (!proc) return -1;
|
||||
|
||||
// Clean up any windows owned by this process
|
||||
// Clean up any windows owned by this process (unmaps pixel pages from desktop)
|
||||
WinServer::CleanupProcess(pid);
|
||||
|
||||
// Free I/O redirect buffers
|
||||
if (proc->outBuf) {
|
||||
Memory::g_pfa->Free(proc->outBuf);
|
||||
proc->outBuf = nullptr;
|
||||
}
|
||||
if (proc->inBuf) {
|
||||
Memory::g_pfa->Free(proc->inBuf);
|
||||
proc->inBuf = nullptr;
|
||||
}
|
||||
|
||||
// Free all user-space pages and page table structures
|
||||
Memory::VMM::Paging::FreeUserHalf(proc->pml4Phys);
|
||||
|
||||
// Free kernel stack (safe — killed process isn't running on single-core)
|
||||
if (proc->stackBase != 0) {
|
||||
Memory::g_pfa->Free((void*)proc->stackBase, Sched::StackPages);
|
||||
proc->stackBase = 0;
|
||||
}
|
||||
|
||||
// Free the PML4 page
|
||||
if (proc->pml4Phys != 0) {
|
||||
Memory::g_pfa->Free((void*)Memory::HHDM(proc->pml4Phys));
|
||||
proc->pml4Phys = 0;
|
||||
}
|
||||
|
||||
proc->state = Sched::ProcessState::Terminated;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user