Ilod updated this revision to Diff 75426.
Ilod added a comment.

Yeah, you're right, the previous code is used for reference was inconsistent 
here. Now I return false and set an error string. Also remove an hacky ifdef 
which was needed on previous implementation (because the master id was updated 
to 0), but now we leave it to -1, so it's not needed anymore.


https://reviews.llvm.org/D25681

Files:
  source/Utility/PseudoTerminal.cpp


Index: source/Utility/PseudoTerminal.cpp
===================================================================
--- source/Utility/PseudoTerminal.cpp
+++ source/Utility/PseudoTerminal.cpp
@@ -50,11 +50,7 @@
 //----------------------------------------------------------------------
 void PseudoTerminal::CloseMasterFileDescriptor() {
   if (m_master_fd >= 0) {
-// Don't call 'close' on m_master_fd for Windows as a dummy implementation of
-// posix_openpt above always gives it a 0 value.
-#ifndef _WIN32
     ::close(m_master_fd);
-#endif
     m_master_fd = invalid_fd;
   }
 }
@@ -81,13 +77,14 @@
 // file descriptor after this object is out of scope or destroyed.
 //
 // RETURNS:
-//  Zero when successful, non-zero indicating an error occurred.
+//  True when successful, false indicating an error occurred.
 //----------------------------------------------------------------------
 bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
                                               size_t error_len) {
   if (error_str)
     error_str[0] = '\0';
 
+#if !defined(LLDB_DISABLE_POSIX)
   // Open the master side of a pseudo terminal
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
@@ -113,6 +110,12 @@
   }
 
   return true;
+#else
+  if (error_str)
+    ::snprintf(error_str, error_len, "%s",
+               "pseudo terminal not supported");
+  return false;
+#endif
 }
 
 //----------------------------------------------------------------------
@@ -124,7 +127,7 @@
 // ReleaseSlaveFileDescriptor() member function.
 //
 // RETURNS:
-//  Zero when successful, non-zero indicating an error occurred.
+//  True when successful, false indicating an error occurred.
 //----------------------------------------------------------------------
 bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
   if (error_str)


Index: source/Utility/PseudoTerminal.cpp
===================================================================
--- source/Utility/PseudoTerminal.cpp
+++ source/Utility/PseudoTerminal.cpp
@@ -50,11 +50,7 @@
 //----------------------------------------------------------------------
 void PseudoTerminal::CloseMasterFileDescriptor() {
   if (m_master_fd >= 0) {
-// Don't call 'close' on m_master_fd for Windows as a dummy implementation of
-// posix_openpt above always gives it a 0 value.
-#ifndef _WIN32
     ::close(m_master_fd);
-#endif
     m_master_fd = invalid_fd;
   }
 }
@@ -81,13 +77,14 @@
 // file descriptor after this object is out of scope or destroyed.
 //
 // RETURNS:
-//  Zero when successful, non-zero indicating an error occurred.
+//  True when successful, false indicating an error occurred.
 //----------------------------------------------------------------------
 bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
                                               size_t error_len) {
   if (error_str)
     error_str[0] = '\0';
 
+#if !defined(LLDB_DISABLE_POSIX)
   // Open the master side of a pseudo terminal
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
@@ -113,6 +110,12 @@
   }
 
   return true;
+#else
+  if (error_str)
+    ::snprintf(error_str, error_len, "%s",
+               "pseudo terminal not supported");
+  return false;
+#endif
 }
 
 //----------------------------------------------------------------------
@@ -124,7 +127,7 @@
 // ReleaseSlaveFileDescriptor() member function.
 //
 // RETURNS:
-//  Zero when successful, non-zero indicating an error occurred.
+//  True when successful, false indicating an error occurred.
 //----------------------------------------------------------------------
 bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
   if (error_str)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to