summaryrefslogtreecommitdiff
path: root/Applications/KeyboardSettings
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-06-28 13:40:10 -0400
committerAndreas Kling <kling@serenityos.org>2020-06-29 12:04:27 +0200
commit12cbc4ad0d57b7f403e0a27b491b098f1431a283 (patch)
treeefe3ef1bb3555c24b3173bbfad4d97c503e3f585 /Applications/KeyboardSettings
parent301ac3c7e5d99f32ac9a70b51844ad7ce8c9d563 (diff)
downloadserenity-12cbc4ad0d57b7f403e0a27b491b098f1431a283.zip
Everywhere: Replace some uses of fork/exec with posix_spawn
It's less code, and it's potentially more efficient once posix_spawn is a real syscall.
Diffstat (limited to 'Applications/KeyboardSettings')
-rw-r--r--Applications/KeyboardSettings/main.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/Applications/KeyboardSettings/main.cpp b/Applications/KeyboardSettings/main.cpp
index c2a36c9344..0cb4aaad5a 100644
--- a/Applications/KeyboardSettings/main.cpp
+++ b/Applications/KeyboardSettings/main.cpp
@@ -40,6 +40,7 @@
#include <LibGUI/MessageBox.h>
#include <LibGUI/WindowServerConnection.h>
#include <LibKeyboard/CharacterMap.h>
+#include <spawn.h>
int main(int argc, char** argv)
{
@@ -123,18 +124,12 @@ int main(int argc, char** argv)
GUI::MessageBox::show("Please select character mapping file.", "Keyboard settings", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
return;
}
-
- pid_t child_pid = fork();
- if (child_pid < 0) {
- perror("fork");
+ pid_t child_pid;
+ const char* argv[] = { "/bin/keymap", character_map_file.characters(), nullptr };
+ if ((errno = posix_spawn(&child_pid, "/bin/keymap", nullptr, nullptr, const_cast<char**>(argv), environ))) {
+ perror("posix_spawn");
exit(1);
}
- if (child_pid == 0) {
- if (execl("/bin/keymap", "/bin/keymap", character_map_file.characters(), nullptr) < 0) {
- perror("execl");
- exit(1);
- }
- }
if (quit)
app.quit();
};