diff options
Diffstat (limited to 'lldb/source/Host/common/PseudoTerminal.cpp')
| -rw-r--r-- | lldb/source/Host/common/PseudoTerminal.cpp | 101 |
1 files changed, 48 insertions, 53 deletions
diff --git a/lldb/source/Host/common/PseudoTerminal.cpp b/lldb/source/Host/common/PseudoTerminal.cpp index 9657cb6523d..c9b290078e1 100644 --- a/lldb/source/Host/common/PseudoTerminal.cpp +++ b/lldb/source/Host/common/PseudoTerminal.cpp @@ -35,10 +35,10 @@ PseudoTerminal::PseudoTerminal() //---------------------------------------------------------------------- // Destructor // -// The destructor will close the master and slave file descriptors -// if they are valid and ownership has not been released using the -// ReleaseMasterFileDescriptor() or the ReleaseSaveFileDescriptor() -// member functions. +// The destructor will close the master and slave file descriptors if they are +// valid and ownership has not been released using the +// ReleaseMasterFileDescriptor() or the ReleaseSaveFileDescriptor() member +// functions. //---------------------------------------------------------------------- PseudoTerminal::~PseudoTerminal() { CloseMasterFileDescriptor(); @@ -66,15 +66,14 @@ void PseudoTerminal::CloseSlaveFileDescriptor() { } //---------------------------------------------------------------------- -// Open the first available pseudo terminal with OFLAG as the -// permissions. The file descriptor is stored in this object and can -// be accessed with the MasterFileDescriptor() accessor. The -// ownership of the master file descriptor can be released using -// the ReleaseMasterFileDescriptor() accessor. If this object has -// a valid master files descriptor when its destructor is called, it -// will close the master file descriptor, therefore clients must -// call ReleaseMasterFileDescriptor() if they wish to use the master -// file descriptor after this object is out of scope or destroyed. +// Open the first available pseudo terminal with OFLAG as the permissions. The +// file descriptor is stored in this object and can be accessed with the +// MasterFileDescriptor() accessor. The ownership of the master file descriptor +// can be released using the ReleaseMasterFileDescriptor() accessor. If this +// object has a valid master files descriptor when its destructor is called, it +// will close the master file descriptor, therefore clients must call +// ReleaseMasterFileDescriptor() if they wish to use the master file descriptor +// after this object is out of scope or destroyed. // // RETURNS: // True when successful, false indicating an error occurred. @@ -118,12 +117,12 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str, } //---------------------------------------------------------------------- -// Open the slave pseudo terminal for the current master pseudo -// terminal. A master pseudo terminal should already be valid prior to -// calling this function (see OpenFirstAvailableMaster()). -// The file descriptor is stored this object's member variables and can -// be accessed via the GetSlaveFileDescriptor(), or released using the -// ReleaseSlaveFileDescriptor() member function. +// Open the slave pseudo terminal for the current master pseudo terminal. A +// master pseudo terminal should already be valid prior to calling this +// function (see OpenFirstAvailableMaster()). The file descriptor is stored +// this object's member variables and can be accessed via the +// GetSlaveFileDescriptor(), or released using the ReleaseSlaveFileDescriptor() +// member function. // // RETURNS: // True when successful, false indicating an error occurred. @@ -152,8 +151,8 @@ bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) { } //---------------------------------------------------------------------- -// Get the name of the slave pseudo terminal. A master pseudo terminal -// should already be valid prior to calling this function (see +// Get the name of the slave pseudo terminal. A master pseudo terminal should +// already be valid prior to calling this function (see // OpenFirstAvailableMaster()). // // RETURNS: @@ -185,18 +184,16 @@ const char *PseudoTerminal::GetSlaveName(char *error_str, // Fork a child process and have its stdio routed to a pseudo terminal. // // In the parent process when a valid pid is returned, the master file -// descriptor can be used as a read/write access to stdio of the -// child process. +// descriptor can be used as a read/write access to stdio of the child process. // -// In the child process the stdin/stdout/stderr will already be routed -// to the slave pseudo terminal and the master file descriptor will be -// closed as it is no longer needed by the child process. +// In the child process the stdin/stdout/stderr will already be routed to the +// slave pseudo terminal and the master file descriptor will be closed as it is +// no longer needed by the child process. // -// This class will close the file descriptors for the master/slave -// when the destructor is called, so be sure to call -// ReleaseMasterFileDescriptor() or ReleaseSlaveFileDescriptor() if any -// file descriptors are going to be used past the lifespan of this -// object. +// This class will close the file descriptors for the master/slave when the +// destructor is called, so be sure to call ReleaseMasterFileDescriptor() or +// ReleaseSlaveFileDescriptor() if any file descriptors are going to be used +// past the lifespan of this object. // // RETURNS: // in the parent process: the pid of the child, or -1 if fork fails @@ -261,49 +258,47 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) { } //---------------------------------------------------------------------- -// The master file descriptor accessor. This object retains ownership -// of the master file descriptor when this accessor is used. Use -// ReleaseMasterFileDescriptor() if you wish this object to release -// ownership of the master file descriptor. +// The master file descriptor accessor. This object retains ownership of the +// master file descriptor when this accessor is used. Use +// ReleaseMasterFileDescriptor() if you wish this object to release ownership +// of the master file descriptor. // -// Returns the master file descriptor, or -1 if the master file -// descriptor is not currently valid. +// Returns the master file descriptor, or -1 if the master file descriptor is +// not currently valid. //---------------------------------------------------------------------- int PseudoTerminal::GetMasterFileDescriptor() const { return m_master_fd; } //---------------------------------------------------------------------- // The slave file descriptor accessor. // -// Returns the slave file descriptor, or -1 if the slave file -// descriptor is not currently valid. +// Returns the slave file descriptor, or -1 if the slave file descriptor is not +// currently valid. //---------------------------------------------------------------------- int PseudoTerminal::GetSlaveFileDescriptor() const { return m_slave_fd; } //---------------------------------------------------------------------- -// Release ownership of the master pseudo terminal file descriptor -// without closing it. The destructor for this class will close the -// master file descriptor if the ownership isn't released using this -// call and the master file descriptor has been opened. +// Release ownership of the master pseudo terminal file descriptor without +// closing it. The destructor for this class will close the master file +// descriptor if the ownership isn't released using this call and the master +// file descriptor has been opened. //---------------------------------------------------------------------- int PseudoTerminal::ReleaseMasterFileDescriptor() { - // Release ownership of the master pseudo terminal file - // descriptor without closing it. (the destructor for this - // class will close it otherwise!) + // Release ownership of the master pseudo terminal file descriptor without + // closing it. (the destructor for this class will close it otherwise!) int fd = m_master_fd; m_master_fd = invalid_fd; return fd; } //---------------------------------------------------------------------- -// Release ownership of the slave pseudo terminal file descriptor -// without closing it. The destructor for this class will close the -// slave file descriptor if the ownership isn't released using this -// call and the slave file descriptor has been opened. +// Release ownership of the slave pseudo terminal file descriptor without +// closing it. The destructor for this class will close the slave file +// descriptor if the ownership isn't released using this call and the slave +// file descriptor has been opened. //---------------------------------------------------------------------- int PseudoTerminal::ReleaseSlaveFileDescriptor() { - // Release ownership of the slave pseudo terminal file - // descriptor without closing it (the destructor for this - // class will close it otherwise!) + // Release ownership of the slave pseudo terminal file descriptor without + // closing it (the destructor for this class will close it otherwise!) int fd = m_slave_fd; m_slave_fd = invalid_fd; return fd; |

