diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2019-11-14 19:22:09 +0300 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-14 20:10:16 +0100 |
commit | 1f5001c581a6b4d13f2d930f228f75b9bafedb50 (patch) | |
tree | 174faa5c622944cb4476b22d740a07c45340885f /DevTools | |
parent | 8484635920fc10c69bbbabf62a14377c31ebc12f (diff) | |
download | serenity-1f5001c581a6b4d13f2d930f228f75b9bafedb50.zip |
HackStudio: Do not spawn an intermediary shell
The Shell also puts each command into its own process group,
which interferes with us trying to do the same here. We don't
really need the shell here anyway, but it means we'll have to
do command splitting ourselves.
Diffstat (limited to 'DevTools')
-rw-r--r-- | DevTools/HackStudio/TerminalWrapper.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/DevTools/HackStudio/TerminalWrapper.cpp b/DevTools/HackStudio/TerminalWrapper.cpp index 52ae3665ac..001a470a2a 100644 --- a/DevTools/HackStudio/TerminalWrapper.cpp +++ b/DevTools/HackStudio/TerminalWrapper.cpp @@ -103,13 +103,17 @@ void TerminalWrapper::run_command(const String& command) perror("ioctl(TIOCSCTTY)"); exit(1); } - const char* args[4] = { "/bin/Shell", nullptr, nullptr, nullptr }; - if (!command.is_empty()) { - args[1] = "-c"; - args[2] = command.characters(); + + setenv("TERM", "xterm", true); + setenv("PATH", "/bin:/usr/bin:/usr/local/bin", true); + + auto parts = command.split(' '); + ASSERT(!parts.is_empty()); + const char** args = (const char**) calloc(parts.size() + 1, sizeof(const char*)); + for (int i = 0; i < parts.size(); i++) { + args[i] = parts[i].characters(); } - const char* envs[] = { "TERM=xterm", "PATH=/bin:/usr/bin:/usr/local/bin", nullptr }; - rc = execve("/bin/Shell", const_cast<char**>(args), const_cast<char**>(envs)); + rc = execvp(args[0], const_cast<char**>(args)); if (rc < 0) { perror("execve"); exit(1); |