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

Userland: Use Core::Process::spawn() instead of posix_spawn() in places

This replaces a bunch of very basic uses of posix_spawn() with the new
Core::Process::spawn().
This commit is contained in:
Andreas Kling 2021-08-06 01:05:32 +02:00
parent 6e65b36973
commit 779316d468
6 changed files with 16 additions and 83 deletions

View file

@ -9,10 +9,8 @@
#include <AK/Vector.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/DirIterator.h>
#include <LibCore/Process.h>
#include <LibDesktop/AppFile.h>
#include <errno.h>
#include <serenity.h>
#include <spawn.h>
namespace Desktop {
@ -134,15 +132,9 @@ bool AppFile::spawn() const
if (!is_valid())
return false;
pid_t child_pid;
const char* argv[] = { executable().characters(), nullptr };
if ((errno = posix_spawn(&child_pid, executable().characters(), nullptr, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
auto pid = Core::Process::spawn(executable());
if (pid < 0)
return false;
} else if (disown(child_pid) < 0) {
perror("disown");
return false;
}
return true;
}