Add '-no-stdio' option to 'process launch' command, which  causes the
inferior to be launched without setting up terminal stdin/stdout for it
(leaving the lldb command line accessible while the program is executing).
Also add a user settings variable, 'target.process.disable-stdio' to allow
the user to set this globally rather than having to use the command option
each time the process is launched.

llvm-svn: 120825
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp
index f7696ac..6b08b1b 100644
--- a/lldb/tools/debugserver/source/debugserver.cpp
+++ b/lldb/tools/debugserver/source/debugserver.cpp
@@ -151,7 +151,7 @@
 // or crash process state.
 //----------------------------------------------------------------------
 RNBRunLoopMode
-RNBRunLoopLaunchInferior (RNBRemoteSP &remote, const char *stdio_path)
+RNBRunLoopLaunchInferior (RNBRemoteSP &remote, const char *stdio_path, bool no_stdio)
 {
     RNBContext& ctx = remote->Context();
 
@@ -209,6 +209,7 @@
                                           &inferior_argv[0],
                                           &inferior_envp[0],
                                           stdio_path,
+                                          no_stdio,
                                           launch_flavor,
                                           g_disable_aslr,
                                           launch_err_str,
@@ -656,6 +657,7 @@
     { "waitfor-duration",   required_argument,  NULL,               'd' },  // The time in seconds to wait for a process to show up by name
     { "native-regs",        no_argument,        NULL,               'r' },  // Specify to use the native registers instead of the gdb defaults for the architecture.
     { "stdio-path",         required_argument,  NULL,               's' },  // Set the STDIO path to be used when launching applications
+    { "no-stdio",           no_argument,        NULL,               'n' },  // Do not set up any stdio (perhaps the program is a GUI program)
     { "setsid",             no_argument,        NULL,               'S' },  // call setsid() to make debugserver run in its own sessions
     { "disable-aslr",       no_argument,        NULL,               'D' },  // Use _POSIX_SPAWN_DISABLE_ASLR to avoid shared library randomization
     { NULL,                 0,                  NULL,               0   }
@@ -698,6 +700,7 @@
     std::string arch_name;
     useconds_t waitfor_interval = 1000;     // Time in usecs between process lists polls when waiting for a process by name, default 1 msec.
     useconds_t waitfor_duration = 0;        // Time in seconds to wait for a process by name, 0 means wait forever.
+    bool no_stdio = false;
 
 #if !defined (DNBLOG_ENABLED)
     compile_options += "(no-logging) ";
@@ -705,7 +708,7 @@
 
     RNBRunLoopMode start_mode = eRNBRunLoopModeExit;
 
-    while ((ch = getopt_long(argc, argv, "a:A:d:gi:vktl:f:w:x:rs:", g_long_options, &long_option_index)) != -1)
+    while ((ch = getopt_long(argc, argv, "a:A:d:gi:vktl:f:w:x:rs:n", g_long_options, &long_option_index)) != -1)
     {
         DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n",
                     ch, (uint8_t)ch,
@@ -856,6 +859,10 @@
                 stdio_path = optarg;
                 break;
 
+            case 'n':
+                no_stdio = true;
+                break;
+                
             case 'S':
                 // Put debugserver into a new session. Terminals group processes
                 // into sessions and when a special terminal key sequences
@@ -1208,7 +1215,7 @@
                 break;
 
             case eRNBRunLoopModeInferiorLaunching:
-                mode = RNBRunLoopLaunchInferior (g_remoteSP, stdio_path.empty() ? NULL : stdio_path.c_str());
+                mode = RNBRunLoopLaunchInferior (g_remoteSP, stdio_path.empty() ? NULL : stdio_path.c_str(), no_stdio);
 
                 if (mode == eRNBRunLoopModeInferiorExecuting)
                 {