mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Run: Use Core::Process::spawn() to launch commands
This commit is contained in:
parent
43529ea25e
commit
3feddbf9da
Notes:
sideshowbarker
2024-07-17 06:00:02 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/3feddbf9da Pull-request: https://github.com/SerenityOS/serenity/pull/17840 Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/kleinesfilmroellchen ✅
1 changed files with 6 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue