diff options
author | MacDue <macdue@dueutil.tech> | 2023-03-15 16:59:31 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-24 22:06:38 +0000 |
commit | 3feddbf9dadecd9e72cfb53bd51339857e9bea35 (patch) | |
tree | 6255068ab6b4e32dee76a82060c5771ad688d2f5 /Userland/Applications/Run | |
parent | 43529ea25ecf8f8aeb58f8715fb4359fc812fb88 (diff) | |
download | serenity-3feddbf9dadecd9e72cfb53bd51339857e9bea35.zip |
Run: Use Core::Process::spawn() to launch commands
Diffstat (limited to 'Userland/Applications/Run')
-rw-r--r-- | Userland/Applications/Run/RunWindow.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index 791c54dfd0..0c02bb1600 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -9,6 +9,7 @@ #include <AK/LexicalPath.h> #include <AK/URL.h> #include <Applications/Run/RunGML.h> +#include <LibCore/Process.h> #include <LibCore/StandardPaths.h> #include <LibDesktop/Launcher.h> #include <LibFileSystem/FileSystem.h> @@ -110,14 +111,12 @@ void RunWindow::do_run() bool RunWindow::run_as_command(DeprecatedString const& run_input) { - pid_t child_pid; - char const* shell_executable = "/bin/Shell"; // TODO query and use the user's preferred shell. - char const* argv[] = { shell_executable, "-c", run_input.characters(), nullptr }; - - if ((errno = posix_spawn(&child_pid, shell_executable, nullptr, nullptr, const_cast<char**>(argv), environ))) { - perror("posix_spawn"); + // TODO: Query and use the user's preferred shell. + auto maybe_child_pid = Core::Process::spawn("/bin/Shell"sv, Array { "-c", run_input.characters() }, {}, Core::Process::KeepAsChild::Yes); + if (maybe_child_pid.is_error()) return false; - } + + pid_t child_pid = maybe_child_pid.release_value(); // Command spawned in child shell. Hide and wait for exit code. int status; |