[Lldb-commits] [lldb] r152569 - /lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp

Greg Clayton gclayton at apple.com
Mon Mar 12 12:02:41 PDT 2012


Author: gclayton
Date: Mon Mar 12 14:02:41 2012
New Revision: 152569

URL: http://llvm.org/viewvc/llvm-project?rev=152569&view=rev
Log:
<rdar://problem/11030692>

SBProcess::PutSTDIN() was not working for a few builds on darwin when using debugserver. This is now fixed.


Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=152569&r1=152568&r2=152569&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Mon Mar 12 14:02:41 2012
@@ -1709,46 +1709,40 @@
             }
         }
 
-		// if no_stdio, then do open file actions, opening /dev/null.
-        if (no_stdio)
-        {
-            err.SetError( ::posix_spawn_file_actions_addopen (&file_actions, STDIN_FILENO, "/dev/null", 
-                                                              O_RDONLY | O_NOCTTY, 0), DNBError::POSIX);
-            if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS))
-                err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDIN_FILENO, path=/dev/null)");
-            
-            err.SetError( ::posix_spawn_file_actions_addopen (&file_actions, STDOUT_FILENO, "/dev/null", 
-                                                              O_WRONLY | O_NOCTTY, 0), DNBError::POSIX);
-            if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS))
-                err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDOUT_FILENO, path=/dev/null)");
-            
-            err.SetError( ::posix_spawn_file_actions_addopen (&file_actions, STDERR_FILENO, "/dev/null", 
-                                                              O_WRONLY | O_NOCTTY, 0), DNBError::POSIX);
-            if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS))
-                err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDERR_FILENO, path=/dev/null)");
-        }
-        else
-        {
-            if ( stdin_path == NULL)  stdin_path = "/dev/null";
-            if (stdout_path == NULL) stdout_path = "/dev/null";
-            if (stderr_path == NULL) stderr_path = "/dev/null";
-            
-            const int slave_fd_in  = open (stdin_path , O_NOCTTY | O_RDONLY);
-            const int slave_fd_out = open (stdout_path, O_NOCTTY | O_CREAT | O_WRONLY , 0640);
-            const int slave_fd_err = open (stderr_path, O_NOCTTY | O_CREAT | O_WRONLY , 0640);
-
-            err.SetError( ::posix_spawn_file_actions_adddup2(&file_actions, slave_fd_err, STDERR_FILENO), DNBError::POSIX);
-            if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
-                err.LogThreaded("::posix_spawn_file_actions_adddup2 ( &file_actions, filedes = %d (\"%s\"), newfiledes = STDERR_FILENO )", slave_fd_err, stderr_path);
-
-            err.SetError( ::posix_spawn_file_actions_adddup2(&file_actions, slave_fd_in, STDIN_FILENO), DNBError::POSIX);
-            if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
-                err.LogThreaded("::posix_spawn_file_actions_adddup2 ( &file_actions, filedes = %d (\"%s\"), newfiledes = STDIN_FILENO )", slave_fd_in, stdin_path);
-
-            err.SetError( ::posix_spawn_file_actions_adddup2(&file_actions, slave_fd_out, STDOUT_FILENO), DNBError::POSIX);
-            if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
-                err.LogThreaded("::posix_spawn_file_actions_adddup2 ( &file_actions, filedes = %d (\"%s\"), newfiledes = STDOUT_FILENO )", slave_fd_out, stdout_path);
-        }
+		// if no_stdio or std paths not supplied, then route to "/dev/null".
+        if (no_stdio || stdin_path == NULL || stdin_path[0] == '\0')
+            stdin_path = "/dev/null";
+        if (no_stdio || stdout_path == NULL || stdout_path[0] == '\0')
+            stdout_path = "/dev/null";
+        if (no_stdio || stderr_path == NULL || stderr_path[0] == '\0')
+            stderr_path = "/dev/null";
+
+        err.SetError( ::posix_spawn_file_actions_addopen (&file_actions,
+                                                          STDIN_FILENO,
+                                                          stdin_path,
+                                                          O_RDONLY | O_NOCTTY,
+                                                          0),
+                     DNBError::POSIX);
+        if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS))
+            err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDIN_FILENO, path='%s')", stdin_path);
+        
+        err.SetError( ::posix_spawn_file_actions_addopen (&file_actions,
+                                                          STDOUT_FILENO,
+                                                          stdout_path,
+                                                          O_WRONLY | O_NOCTTY | O_CREAT,
+                                                          0640),
+                     DNBError::POSIX);
+        if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS))
+            err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDOUT_FILENO, path='%s')", stdout_path);
+        
+        err.SetError( ::posix_spawn_file_actions_addopen (&file_actions,
+                                                          STDERR_FILENO,
+                                                          stderr_path,
+                                                          O_WRONLY | O_NOCTTY | O_CREAT,
+                                                          0640),
+                     DNBError::POSIX);
+        if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS))
+            err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDERR_FILENO, path='%s')", stderr_path);
 
         // TODO: Verify if we can set the working directory back immediately
         // after the posix_spawnp call without creating a race condition???





More information about the lldb-commits mailing list