mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibCore: Add a Core::Process action to close a file after spawning
This commit is contained in:
parent
fecd08ce64
commit
dc52404aec
Notes:
sideshowbarker
2024-07-17 09:39:38 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/dc52404aec Pull-request: https://github.com/SerenityOS/serenity/pull/24092 Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 11 additions and 3 deletions
|
@ -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 {};
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,10 @@ struct OpenFile {
|
|||
mode_t permissions = 0600;
|
||||
};
|
||||
|
||||
struct CloseFile {
|
||||
int fd { -1 };
|
||||
};
|
||||
|
||||
// FIXME: Implement other file actions
|
||||
|
||||
}
|
||||
|
@ -31,9 +35,9 @@ struct OpenFile {
|
|||
struct ProcessSpawnOptions {
|
||||
ByteString executable;
|
||||
bool search_for_executable_in_path { false };
|
||||
Vector<ByteString> const& arguments = {};
|
||||
Optional<ByteString> working_directory = {};
|
||||
Vector<Variant<FileAction::OpenFile>> const& file_actions = {};
|
||||
Vector<ByteString> const& arguments {};
|
||||
Optional<ByteString> working_directory {};
|
||||
Vector<Variant<FileAction::OpenFile, FileAction::CloseFile>> const& file_actions {};
|
||||
};
|
||||
|
||||
class Process {
|
||||
|
|
Loading…
Reference in a new issue