LibCore: Add a Core::Process action to close a file after spawning

This commit is contained in:
Timothy Flynn
2024-04-23 15:31:07 -04:00
committed by Andrew Kaster
parent fecd08ce64
commit dc52404aec
2 changed files with 11 additions and 3 deletions

View File

@@ -90,6 +90,10 @@ ErrorOr<Process> Process::spawn(ProcessSpawnOptions const& options)
File::open_mode_to_options(action.mode | Core::File::OpenMode::KeepOnExec),
action.permissions));
return {};
},
[&](FileAction::CloseFile const& action) -> ErrorOr<void> {
CHECK(posix_spawn_file_actions_addclose(&spawn_actions, action.fd));
return {};
}));
}