1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

LibCore: Return ErrorOr<pid_t> and support arguments in Process::spawn

This makes the wrapper more like the rest in LibCore, and also
removes the annoying limitation of not supporting arguments.

There are three overloads one for String, char const *, and StringView
argument lists. As long as there are <= 10 arguments the argv list
will be allocated inline, otherwise on the heap.
This commit is contained in:
MacDue 2022-05-10 00:24:15 +01:00 committed by Linus Groh
parent 0295d79339
commit 3fc0350caf
11 changed files with 77 additions and 28 deletions

View file

@ -109,7 +109,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu()
auto system_menu = TRY(GUI::Menu::try_create("\xE2\x9A\xA1")); // HIGH VOLTAGE SIGN
system_menu->add_action(GUI::Action::create("&About SerenityOS", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladyball.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Core::Process::spawn("/bin/About"sv);
MUST(Core::Process::spawn("/bin/About"sv));
}));
system_menu->add_separator();
@ -229,12 +229,12 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu()
}
system_menu->add_action(GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-settings.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Core::Process::spawn("/bin/Settings"sv);
MUST(Core::Process::spawn("/bin/Settings"sv));
}));
system_menu->add_separator();
system_menu->add_action(GUI::Action::create("&Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
Core::Process::spawn("/bin/Help"sv);
MUST(Core::Process::spawn("/bin/Help"sv));
}));
system_menu->add_action(GUI::Action::create("&Run...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-run.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
posix_spawn_file_actions_t spawn_actions;