From 961389dee828b54423583ca882cfe505176b2019 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Thu, 7 Dec 2023 00:18:09 -0800 Subject: [PATCH] [Teton] Duplicate yellowstone cap before spawning processes. --- sys/teton/terminal.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/teton/terminal.cpp b/sys/teton/terminal.cpp index fda6396..c4d14c9 100644 --- a/sys/teton/terminal.cpp +++ b/sys/teton/terminal.cpp @@ -68,9 +68,14 @@ void Terminal::ExecuteCommand(const glcr::String& command) { } auto file = mmth::File::Open(tokens[1]); - // TODO: Wait until the process exits. - auto error_or_cap = mmth::SpawnProcessFromElfRegion( - (uint64_t)file.raw_ptr(), gInitEndpointCap); + z_cap_t endpoint; + if (ZCapDuplicate(gInitEndpointCap, kZionPerm_All, &endpoint) != glcr::OK) { + console_.WriteString("Couldn't duplicate yellowstone cap for spawn"); + return; + } + + auto error_or_cap = + mmth::SpawnProcessFromElfRegion((uint64_t)file.raw_ptr(), endpoint); if (!error_or_cap.ok()) { console_.WriteString( glcr::StrFormat("Error: {}\n", error_or_cap.error()));