15ffd83dbSDimitry Andric //===-- ProcessLaunchInfo.cpp ---------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include <climits>
100b57cec5SDimitry Andric 
110b57cec5SDimitry Andric #include "lldb/Host/Config.h"
120b57cec5SDimitry Andric #include "lldb/Host/FileAction.h"
130b57cec5SDimitry Andric #include "lldb/Host/FileSystem.h"
140b57cec5SDimitry Andric #include "lldb/Host/HostInfo.h"
150b57cec5SDimitry Andric #include "lldb/Host/ProcessLaunchInfo.h"
1681ad6265SDimitry Andric #include "lldb/Utility/LLDBLog.h"
170b57cec5SDimitry Andric #include "lldb/Utility/Log.h"
180b57cec5SDimitry Andric #include "lldb/Utility/StreamString.h"
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric #include "llvm/Support/ConvertUTF.h"
210b57cec5SDimitry Andric #include "llvm/Support/FileSystem.h"
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric #if !defined(_WIN32)
24fe6060f1SDimitry Andric #include <climits>
250b57cec5SDimitry Andric #endif
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric using namespace lldb;
280b57cec5SDimitry Andric using namespace lldb_private;
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric // ProcessLaunchInfo member functions
310b57cec5SDimitry Andric 
ProcessLaunchInfo()320b57cec5SDimitry Andric ProcessLaunchInfo::ProcessLaunchInfo()
330b57cec5SDimitry Andric     : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
3406c3fb27SDimitry Andric       m_file_actions(), m_pty(new PseudoTerminal), m_monitor_callback(nullptr) {
3506c3fb27SDimitry Andric }
360b57cec5SDimitry Andric 
ProcessLaunchInfo(const FileSpec & stdin_file_spec,const FileSpec & stdout_file_spec,const FileSpec & stderr_file_spec,const FileSpec & working_directory,uint32_t launch_flags)370b57cec5SDimitry Andric ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
380b57cec5SDimitry Andric                                      const FileSpec &stdout_file_spec,
390b57cec5SDimitry Andric                                      const FileSpec &stderr_file_spec,
400b57cec5SDimitry Andric                                      const FileSpec &working_directory,
410b57cec5SDimitry Andric                                      uint32_t launch_flags)
420b57cec5SDimitry Andric     : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(launch_flags),
4306c3fb27SDimitry Andric       m_file_actions(), m_pty(new PseudoTerminal) {
440b57cec5SDimitry Andric   if (stdin_file_spec) {
450b57cec5SDimitry Andric     FileAction file_action;
460b57cec5SDimitry Andric     const bool read = true;
470b57cec5SDimitry Andric     const bool write = false;
480b57cec5SDimitry Andric     if (file_action.Open(STDIN_FILENO, stdin_file_spec, read, write))
490b57cec5SDimitry Andric       AppendFileAction(file_action);
500b57cec5SDimitry Andric   }
510b57cec5SDimitry Andric   if (stdout_file_spec) {
520b57cec5SDimitry Andric     FileAction file_action;
530b57cec5SDimitry Andric     const bool read = false;
540b57cec5SDimitry Andric     const bool write = true;
550b57cec5SDimitry Andric     if (file_action.Open(STDOUT_FILENO, stdout_file_spec, read, write))
560b57cec5SDimitry Andric       AppendFileAction(file_action);
570b57cec5SDimitry Andric   }
580b57cec5SDimitry Andric   if (stderr_file_spec) {
590b57cec5SDimitry Andric     FileAction file_action;
600b57cec5SDimitry Andric     const bool read = false;
610b57cec5SDimitry Andric     const bool write = true;
620b57cec5SDimitry Andric     if (file_action.Open(STDERR_FILENO, stderr_file_spec, read, write))
630b57cec5SDimitry Andric       AppendFileAction(file_action);
640b57cec5SDimitry Andric   }
650b57cec5SDimitry Andric   if (working_directory)
660b57cec5SDimitry Andric     SetWorkingDirectory(working_directory);
670b57cec5SDimitry Andric }
680b57cec5SDimitry Andric 
AppendCloseFileAction(int fd)690b57cec5SDimitry Andric bool ProcessLaunchInfo::AppendCloseFileAction(int fd) {
700b57cec5SDimitry Andric   FileAction file_action;
710b57cec5SDimitry Andric   if (file_action.Close(fd)) {
720b57cec5SDimitry Andric     AppendFileAction(file_action);
730b57cec5SDimitry Andric     return true;
740b57cec5SDimitry Andric   }
750b57cec5SDimitry Andric   return false;
760b57cec5SDimitry Andric }
770b57cec5SDimitry Andric 
AppendDuplicateFileAction(int fd,int dup_fd)780b57cec5SDimitry Andric bool ProcessLaunchInfo::AppendDuplicateFileAction(int fd, int dup_fd) {
790b57cec5SDimitry Andric   FileAction file_action;
800b57cec5SDimitry Andric   if (file_action.Duplicate(fd, dup_fd)) {
810b57cec5SDimitry Andric     AppendFileAction(file_action);
820b57cec5SDimitry Andric     return true;
830b57cec5SDimitry Andric   }
840b57cec5SDimitry Andric   return false;
850b57cec5SDimitry Andric }
860b57cec5SDimitry Andric 
AppendOpenFileAction(int fd,const FileSpec & file_spec,bool read,bool write)870b57cec5SDimitry Andric bool ProcessLaunchInfo::AppendOpenFileAction(int fd, const FileSpec &file_spec,
880b57cec5SDimitry Andric                                              bool read, bool write) {
890b57cec5SDimitry Andric   FileAction file_action;
900b57cec5SDimitry Andric   if (file_action.Open(fd, file_spec, read, write)) {
910b57cec5SDimitry Andric     AppendFileAction(file_action);
920b57cec5SDimitry Andric     return true;
930b57cec5SDimitry Andric   }
940b57cec5SDimitry Andric   return false;
950b57cec5SDimitry Andric }
960b57cec5SDimitry Andric 
AppendSuppressFileAction(int fd,bool read,bool write)970b57cec5SDimitry Andric bool ProcessLaunchInfo::AppendSuppressFileAction(int fd, bool read,
980b57cec5SDimitry Andric                                                  bool write) {
990b57cec5SDimitry Andric   FileAction file_action;
1000b57cec5SDimitry Andric   if (file_action.Open(fd, FileSpec(FileSystem::DEV_NULL), read, write)) {
1010b57cec5SDimitry Andric     AppendFileAction(file_action);
1020b57cec5SDimitry Andric     return true;
1030b57cec5SDimitry Andric   }
1040b57cec5SDimitry Andric   return false;
1050b57cec5SDimitry Andric }
1060b57cec5SDimitry Andric 
GetFileActionAtIndex(size_t idx) const1070b57cec5SDimitry Andric const FileAction *ProcessLaunchInfo::GetFileActionAtIndex(size_t idx) const {
1080b57cec5SDimitry Andric   if (idx < m_file_actions.size())
1090b57cec5SDimitry Andric     return &m_file_actions[idx];
1100b57cec5SDimitry Andric   return nullptr;
1110b57cec5SDimitry Andric }
1120b57cec5SDimitry Andric 
GetFileActionForFD(int fd) const1130b57cec5SDimitry Andric const FileAction *ProcessLaunchInfo::GetFileActionForFD(int fd) const {
1140b57cec5SDimitry Andric   for (size_t idx = 0, count = m_file_actions.size(); idx < count; ++idx) {
1150b57cec5SDimitry Andric     if (m_file_actions[idx].GetFD() == fd)
1160b57cec5SDimitry Andric       return &m_file_actions[idx];
1170b57cec5SDimitry Andric   }
1180b57cec5SDimitry Andric   return nullptr;
1190b57cec5SDimitry Andric }
1200b57cec5SDimitry Andric 
GetWorkingDirectory() const1210b57cec5SDimitry Andric const FileSpec &ProcessLaunchInfo::GetWorkingDirectory() const {
1220b57cec5SDimitry Andric   return m_working_dir;
1230b57cec5SDimitry Andric }
1240b57cec5SDimitry Andric 
SetWorkingDirectory(const FileSpec & working_dir)1250b57cec5SDimitry Andric void ProcessLaunchInfo::SetWorkingDirectory(const FileSpec &working_dir) {
1260b57cec5SDimitry Andric   m_working_dir = working_dir;
1270b57cec5SDimitry Andric }
1280b57cec5SDimitry Andric 
GetProcessPluginName() const12906c3fb27SDimitry Andric llvm::StringRef ProcessLaunchInfo::GetProcessPluginName() const {
13006c3fb27SDimitry Andric   return llvm::StringRef(m_plugin_name);
1310b57cec5SDimitry Andric }
1320b57cec5SDimitry Andric 
SetProcessPluginName(llvm::StringRef plugin)1330b57cec5SDimitry Andric void ProcessLaunchInfo::SetProcessPluginName(llvm::StringRef plugin) {
1345ffd83dbSDimitry Andric   m_plugin_name = std::string(plugin);
1350b57cec5SDimitry Andric }
1360b57cec5SDimitry Andric 
GetShell() const1370b57cec5SDimitry Andric const FileSpec &ProcessLaunchInfo::GetShell() const { return m_shell; }
1380b57cec5SDimitry Andric 
SetShell(const FileSpec & shell)1390b57cec5SDimitry Andric void ProcessLaunchInfo::SetShell(const FileSpec &shell) {
1400b57cec5SDimitry Andric   m_shell = shell;
1410b57cec5SDimitry Andric   if (m_shell) {
1420b57cec5SDimitry Andric     FileSystem::Instance().ResolveExecutableLocation(m_shell);
1430b57cec5SDimitry Andric     m_flags.Set(lldb::eLaunchFlagLaunchInShell);
1440b57cec5SDimitry Andric   } else
1450b57cec5SDimitry Andric     m_flags.Clear(lldb::eLaunchFlagLaunchInShell);
1460b57cec5SDimitry Andric }
1470b57cec5SDimitry Andric 
SetLaunchInSeparateProcessGroup(bool separate)1480b57cec5SDimitry Andric void ProcessLaunchInfo::SetLaunchInSeparateProcessGroup(bool separate) {
1490b57cec5SDimitry Andric   if (separate)
1500b57cec5SDimitry Andric     m_flags.Set(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
1510b57cec5SDimitry Andric   else
1520b57cec5SDimitry Andric     m_flags.Clear(lldb::eLaunchFlagLaunchInSeparateProcessGroup);
1530b57cec5SDimitry Andric }
1540b57cec5SDimitry Andric 
SetShellExpandArguments(bool expand)1550b57cec5SDimitry Andric void ProcessLaunchInfo::SetShellExpandArguments(bool expand) {
1560b57cec5SDimitry Andric   if (expand)
1570b57cec5SDimitry Andric     m_flags.Set(lldb::eLaunchFlagShellExpandArguments);
1580b57cec5SDimitry Andric   else
1590b57cec5SDimitry Andric     m_flags.Clear(lldb::eLaunchFlagShellExpandArguments);
1600b57cec5SDimitry Andric }
1610b57cec5SDimitry Andric 
Clear()1620b57cec5SDimitry Andric void ProcessLaunchInfo::Clear() {
1630b57cec5SDimitry Andric   ProcessInfo::Clear();
1640b57cec5SDimitry Andric   m_working_dir.Clear();
1650b57cec5SDimitry Andric   m_plugin_name.clear();
1660b57cec5SDimitry Andric   m_shell.Clear();
1670b57cec5SDimitry Andric   m_flags.Clear();
1680b57cec5SDimitry Andric   m_file_actions.clear();
1690b57cec5SDimitry Andric   m_resume_count = 0;
1700b57cec5SDimitry Andric   m_listener_sp.reset();
1710b57cec5SDimitry Andric   m_hijack_listener_sp.reset();
1720b57cec5SDimitry Andric }
1730b57cec5SDimitry Andric 
NoOpMonitorCallback(lldb::pid_t pid,int signal,int status)17481ad6265SDimitry Andric void ProcessLaunchInfo::NoOpMonitorCallback(lldb::pid_t pid, int signal,
17581ad6265SDimitry Andric                                             int status) {
17681ad6265SDimitry Andric   Log *log = GetLog(LLDBLog::Process);
17781ad6265SDimitry Andric   LLDB_LOG(log, "pid = {0}, signal = {1}, status = {2}", pid, signal, status);
1780b57cec5SDimitry Andric }
1790b57cec5SDimitry Andric 
MonitorProcess() const1800b57cec5SDimitry Andric bool ProcessLaunchInfo::MonitorProcess() const {
1810b57cec5SDimitry Andric   if (m_monitor_callback && ProcessIDIsValid()) {
1820b57cec5SDimitry Andric     llvm::Expected<HostThread> maybe_thread =
18381ad6265SDimitry Andric         Host::StartMonitoringChildProcess(m_monitor_callback, GetProcessID());
1840b57cec5SDimitry Andric     if (!maybe_thread)
18506c3fb27SDimitry Andric       LLDB_LOG_ERROR(GetLog(LLDBLog::Host), maybe_thread.takeError(),
18606c3fb27SDimitry Andric                      "failed to launch host thread: {0}");
1870b57cec5SDimitry Andric     return true;
1880b57cec5SDimitry Andric   }
1890b57cec5SDimitry Andric   return false;
1900b57cec5SDimitry Andric }
1910b57cec5SDimitry Andric 
SetDetachOnError(bool enable)1920b57cec5SDimitry Andric void ProcessLaunchInfo::SetDetachOnError(bool enable) {
1930b57cec5SDimitry Andric   if (enable)
1940b57cec5SDimitry Andric     m_flags.Set(lldb::eLaunchFlagDetachOnError);
1950b57cec5SDimitry Andric   else
1960b57cec5SDimitry Andric     m_flags.Clear(lldb::eLaunchFlagDetachOnError);
1970b57cec5SDimitry Andric }
1980b57cec5SDimitry Andric 
SetUpPtyRedirection()1990b57cec5SDimitry Andric llvm::Error ProcessLaunchInfo::SetUpPtyRedirection() {
20081ad6265SDimitry Andric   Log *log = GetLog(LLDBLog::Process);
2010eae32dcSDimitry Andric 
2020eae32dcSDimitry Andric   bool stdin_free = GetFileActionForFD(STDIN_FILENO) == nullptr;
2030eae32dcSDimitry Andric   bool stdout_free = GetFileActionForFD(STDOUT_FILENO) == nullptr;
2040eae32dcSDimitry Andric   bool stderr_free = GetFileActionForFD(STDERR_FILENO) == nullptr;
2050eae32dcSDimitry Andric   bool any_free = stdin_free || stdout_free || stderr_free;
2060eae32dcSDimitry Andric   if (!any_free)
2070eae32dcSDimitry Andric     return llvm::Error::success();
2080eae32dcSDimitry Andric 
2090b57cec5SDimitry Andric   LLDB_LOG(log, "Generating a pty to use for stdin/out/err");
2100b57cec5SDimitry Andric 
2110b57cec5SDimitry Andric   int open_flags = O_RDWR | O_NOCTTY;
2120b57cec5SDimitry Andric #if !defined(_WIN32)
2130b57cec5SDimitry Andric   // We really shouldn't be specifying platform specific flags that are
2140b57cec5SDimitry Andric   // intended for a system call in generic code.  But this will have to
2150b57cec5SDimitry Andric   // do for now.
2160b57cec5SDimitry Andric   open_flags |= O_CLOEXEC;
2170b57cec5SDimitry Andric #endif
218e8d8bef9SDimitry Andric   if (llvm::Error Err = m_pty->OpenFirstAvailablePrimary(open_flags))
219e8d8bef9SDimitry Andric     return Err;
220e8d8bef9SDimitry Andric 
221e8d8bef9SDimitry Andric   const FileSpec secondary_file_spec(m_pty->GetSecondaryName());
2220b57cec5SDimitry Andric 
2230eae32dcSDimitry Andric   if (stdin_free)
2245ffd83dbSDimitry Andric     AppendOpenFileAction(STDIN_FILENO, secondary_file_spec, true, false);
2250b57cec5SDimitry Andric 
2260eae32dcSDimitry Andric   if (stdout_free)
2275ffd83dbSDimitry Andric     AppendOpenFileAction(STDOUT_FILENO, secondary_file_spec, false, true);
2280b57cec5SDimitry Andric 
2290eae32dcSDimitry Andric   if (stderr_free)
2305ffd83dbSDimitry Andric     AppendOpenFileAction(STDERR_FILENO, secondary_file_spec, false, true);
2310b57cec5SDimitry Andric   return llvm::Error::success();
2320b57cec5SDimitry Andric }
2330b57cec5SDimitry Andric 
ConvertArgumentsForLaunchingInShell(Status & error,bool will_debug,bool first_arg_is_full_shell_command,uint32_t num_resumes)2340b57cec5SDimitry Andric bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(
235e8d8bef9SDimitry Andric     Status &error, bool will_debug, bool first_arg_is_full_shell_command,
236e8d8bef9SDimitry Andric     uint32_t num_resumes) {
2370b57cec5SDimitry Andric   error.Clear();
2380b57cec5SDimitry Andric 
2390b57cec5SDimitry Andric   if (GetFlags().Test(eLaunchFlagLaunchInShell)) {
2400b57cec5SDimitry Andric     if (m_shell) {
2410b57cec5SDimitry Andric       std::string shell_executable = m_shell.GetPath();
2420b57cec5SDimitry Andric 
2430b57cec5SDimitry Andric       const char **argv = GetArguments().GetConstArgumentVector();
2440b57cec5SDimitry Andric       if (argv == nullptr || argv[0] == nullptr)
2450b57cec5SDimitry Andric         return false;
2460b57cec5SDimitry Andric       Args shell_arguments;
2470b57cec5SDimitry Andric       shell_arguments.AppendArgument(shell_executable);
2480b57cec5SDimitry Andric       const llvm::Triple &triple = GetArchitecture().GetTriple();
2490b57cec5SDimitry Andric       if (triple.getOS() == llvm::Triple::Win32 &&
2500b57cec5SDimitry Andric           !triple.isWindowsCygwinEnvironment())
2510b57cec5SDimitry Andric         shell_arguments.AppendArgument(llvm::StringRef("/C"));
2520b57cec5SDimitry Andric       else
2530b57cec5SDimitry Andric         shell_arguments.AppendArgument(llvm::StringRef("-c"));
2540b57cec5SDimitry Andric 
2550b57cec5SDimitry Andric       StreamString shell_command;
2560b57cec5SDimitry Andric       if (will_debug) {
2570b57cec5SDimitry Andric         // Add a modified PATH environment variable in case argv[0] is a
2580b57cec5SDimitry Andric         // relative path.
2590b57cec5SDimitry Andric         const char *argv0 = argv[0];
2600b57cec5SDimitry Andric         FileSpec arg_spec(argv0);
2610b57cec5SDimitry Andric         if (arg_spec.IsRelative()) {
2620b57cec5SDimitry Andric           // We have a relative path to our executable which may not work if we
2630b57cec5SDimitry Andric           // just try to run "a.out" (without it being converted to "./a.out")
2640b57cec5SDimitry Andric           FileSpec working_dir = GetWorkingDirectory();
2650b57cec5SDimitry Andric           // Be sure to put quotes around PATH's value in case any paths have
2660b57cec5SDimitry Andric           // spaces...
2670b57cec5SDimitry Andric           std::string new_path("PATH=\"");
2680b57cec5SDimitry Andric           const size_t empty_path_len = new_path.size();
2690b57cec5SDimitry Andric 
2700b57cec5SDimitry Andric           if (working_dir) {
2710b57cec5SDimitry Andric             new_path += working_dir.GetPath();
2720b57cec5SDimitry Andric           } else {
2730b57cec5SDimitry Andric             llvm::SmallString<64> cwd;
2740b57cec5SDimitry Andric             if (! llvm::sys::fs::current_path(cwd))
2750b57cec5SDimitry Andric               new_path += cwd;
2760b57cec5SDimitry Andric           }
2770b57cec5SDimitry Andric           std::string curr_path;
2780b57cec5SDimitry Andric           if (HostInfo::GetEnvironmentVar("PATH", curr_path)) {
2790b57cec5SDimitry Andric             if (new_path.size() > empty_path_len)
2800b57cec5SDimitry Andric               new_path += ':';
2810b57cec5SDimitry Andric             new_path += curr_path;
2820b57cec5SDimitry Andric           }
2830b57cec5SDimitry Andric           new_path += "\" ";
2840b57cec5SDimitry Andric           shell_command.PutCString(new_path);
2850b57cec5SDimitry Andric         }
2860b57cec5SDimitry Andric 
2870b57cec5SDimitry Andric         if (triple.getOS() != llvm::Triple::Win32 ||
2880b57cec5SDimitry Andric             triple.isWindowsCygwinEnvironment())
2890b57cec5SDimitry Andric           shell_command.PutCString("exec");
2900b57cec5SDimitry Andric 
2910b57cec5SDimitry Andric         // Only Apple supports /usr/bin/arch being able to specify the
2920b57cec5SDimitry Andric         // architecture
2930b57cec5SDimitry Andric         if (GetArchitecture().IsValid() && // Valid architecture
2940b57cec5SDimitry Andric             GetArchitecture().GetTriple().getVendor() ==
2950b57cec5SDimitry Andric                 llvm::Triple::Apple && // Apple only
2960b57cec5SDimitry Andric             GetArchitecture().GetCore() !=
2970b57cec5SDimitry Andric                 ArchSpec::eCore_x86_64_x86_64h) // Don't do this for x86_64h
2980b57cec5SDimitry Andric         {
2990b57cec5SDimitry Andric           shell_command.Printf(" /usr/bin/arch -arch %s",
3000b57cec5SDimitry Andric                                GetArchitecture().GetArchitectureName());
3010b57cec5SDimitry Andric           // Set the resume count to 2:
3020b57cec5SDimitry Andric           // 1 - stop in shell
3030b57cec5SDimitry Andric           // 2 - stop in /usr/bin/arch
3040b57cec5SDimitry Andric           // 3 - then we will stop in our program
3050b57cec5SDimitry Andric           SetResumeCount(num_resumes + 1);
3060b57cec5SDimitry Andric         } else {
3070b57cec5SDimitry Andric           // Set the resume count to 1:
3080b57cec5SDimitry Andric           // 1 - stop in shell
3090b57cec5SDimitry Andric           // 2 - then we will stop in our program
3100b57cec5SDimitry Andric           SetResumeCount(num_resumes);
3110b57cec5SDimitry Andric         }
3120b57cec5SDimitry Andric       }
3130b57cec5SDimitry Andric 
3140b57cec5SDimitry Andric       if (first_arg_is_full_shell_command) {
3150b57cec5SDimitry Andric         // There should only be one argument that is the shell command itself
3160b57cec5SDimitry Andric         // to be used as is
3170b57cec5SDimitry Andric         if (argv[0] && !argv[1])
3180b57cec5SDimitry Andric           shell_command.Printf("%s", argv[0]);
3190b57cec5SDimitry Andric         else
3200b57cec5SDimitry Andric           return false;
3210b57cec5SDimitry Andric       } else {
3220b57cec5SDimitry Andric         for (size_t i = 0; argv[i] != nullptr; ++i) {
323e8d8bef9SDimitry Andric           std::string safe_arg = Args::GetShellSafeArgument(m_shell, argv[i]);
32406c3fb27SDimitry Andric           if (safe_arg.empty())
32506c3fb27SDimitry Andric             safe_arg = "\"\"";
326e8d8bef9SDimitry Andric           // Add a space to separate this arg from the previous one.
327e8d8bef9SDimitry Andric           shell_command.PutCString(" ");
328e8d8bef9SDimitry Andric           shell_command.PutCString(safe_arg);
3290b57cec5SDimitry Andric         }
3300b57cec5SDimitry Andric       }
3310b57cec5SDimitry Andric       shell_arguments.AppendArgument(shell_command.GetString());
3320b57cec5SDimitry Andric       m_executable = m_shell;
3330b57cec5SDimitry Andric       m_arguments = shell_arguments;
3340b57cec5SDimitry Andric       return true;
3350b57cec5SDimitry Andric     } else {
3360b57cec5SDimitry Andric       error.SetErrorString("invalid shell path");
3370b57cec5SDimitry Andric     }
3380b57cec5SDimitry Andric   } else {
3390b57cec5SDimitry Andric     error.SetErrorString("not launching in shell");
3400b57cec5SDimitry Andric   }
3410b57cec5SDimitry Andric   return false;
3420b57cec5SDimitry Andric }
343