[Lldb-commits] [lldb] r230492 - Truncate target file for stdout and stderr

Tamas Berghammer tberghammer at google.com
Wed Feb 25 05:21:45 PST 2015


Author: tberghammer
Date: Wed Feb 25 07:21:45 2015
New Revision: 230492

URL: http://llvm.org/viewvc/llvm-project?rev=230492&view=rev
Log:
Truncate target file for stdout and stderr

Add O_TRUNC when opening file for redirecting stdout and stderr of the
process. It is neccessary because if the file exists then on some
platform the original content is kept while it isn't overwritten by the
new data causing pollution of the saved stdout and stderr.

Modified:
    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=230492&r1=230491&r2=230492&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Wed Feb 25 07:21:45 2015
@@ -1564,11 +1564,11 @@ NativeProcessLinux::Launch(LaunchArgs *a
                 exit(eDupStdinFailed);
 
         if (!args->m_stdout_path.empty ())
-            if (!DupDescriptor(args->m_stdout_path.c_str (), STDOUT_FILENO, O_WRONLY | O_CREAT))
+            if (!DupDescriptor(args->m_stdout_path.c_str (), STDOUT_FILENO, O_WRONLY | O_CREAT | O_TRUNC))
                 exit(eDupStdoutFailed);
 
         if (!args->m_stderr_path.empty ())
-            if (!DupDescriptor(args->m_stderr_path.c_str (), STDERR_FILENO, O_WRONLY | O_CREAT))
+            if (!DupDescriptor(args->m_stderr_path.c_str (), STDERR_FILENO, O_WRONLY | O_CREAT | O_TRUNC))
                 exit(eDupStderrFailed);
 
         // Change working directory





More information about the lldb-commits mailing list