diff options
| author | Stephen Wilson <wilsons@start.ca> | 2011-03-23 02:14:42 +0000 |
|---|---|---|
| committer | Stephen Wilson <wilsons@start.ca> | 2011-03-23 02:14:42 +0000 |
| commit | 26977167bc038801ecf3543104dd17c790d15975 (patch) | |
| tree | 08f93eae527b264abb35867dc12065cfb5016939 /lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp | |
| parent | 0c16aa6d39be6e37b7c8c86416a261cbb0c55bd1 (diff) | |
| download | bcm5719-llvm-26977167bc038801ecf3543104dd17c790d15975.tar.gz bcm5719-llvm-26977167bc038801ecf3543104dd17c790d15975.zip | |
linux: simple support for process input and output
llvm-svn: 128137
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index 490ca6f60a3..c5909c85a6d 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -114,6 +114,27 @@ DoWriteMemory(lldb::pid_t pid, unsigned word_size, return bytes_written; } +// Simple helper function to ensure flags are enabled on the given file +// descriptor. +static bool +EnsureFDFlags(int fd, int flags, Error &error) +{ + int status; + + if ((status = fcntl(fd, F_GETFL)) == -1) + { + error.SetErrorToErrno(); + return false; + } + + if (fcntl(fd, F_SETFL, status | flags) == -1) + { + error.SetErrorToErrno(); + return false; + } + + return true; +} //------------------------------------------------------------------------------ /// @class Operation @@ -706,6 +727,12 @@ ProcessMonitor::Launch(LaunchArgs *args) monitor->m_terminal_fd = terminal.ReleaseMasterFileDescriptor(); monitor->m_pid = pid; + // Set the terminal fd to be in non blocking mode (it simplifies the + // implementation of ProcessLinux::GetSTDOUT to have a non-blocking + // descriptor to read from). + if (!EnsureFDFlags(monitor->m_terminal_fd, O_NONBLOCK, args->m_error)) + goto FINISH; + // Update the process thread list with this new thread and mark it as // current. inferior.reset(new LinuxThread(process, pid)); |

