mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:27:43 +00:00
Services: Use Core::Process::spawn() for common process spawn pattern
This commit is contained in:
parent
e547f5887e
commit
5e5a055455
3 changed files with 12 additions and 35 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Process.h>
|
||||
#include <WindowServer/KeymapSwitcher.h>
|
||||
#include <spawn.h>
|
||||
#include <unistd.h>
|
||||
|
@ -101,12 +102,9 @@ String KeymapSwitcher::get_current_keymap() const
|
|||
|
||||
void KeymapSwitcher::setkeymap(const AK::String& keymap)
|
||||
{
|
||||
pid_t child_pid;
|
||||
char const* argv[] = { "/bin/keymap", "-m", keymap.characters(), nullptr };
|
||||
if ((errno = posix_spawn(&child_pid, "/bin/keymap", nullptr, nullptr, const_cast<char**>(argv), environ))) {
|
||||
perror("posix_spawn");
|
||||
if (Core::Process::spawn("/bin/keymap", Array { "-m", keymap.characters() }).is_error())
|
||||
dbgln("Failed to call /bin/keymap, error: {} ({})", errno, strerror(errno));
|
||||
}
|
||||
|
||||
if (on_keymap_change)
|
||||
on_keymap_change(keymap);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue