Author: jingham
Date: Thu Feb 27 13:48:13 2014
New Revision: 202426

URL: http://llvm.org/viewvc/llvm-project?rev=202426&view=rev
Log:
Check call to fgetc for EINTR.

<rdar://problem/16140277>

Modified:
    lldb/trunk/source/Host/common/Editline.cpp

Modified: lldb/trunk/source/Host/common/Editline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Editline.cpp?rev=202426&r1=202425&r2=202426&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Editline.cpp (original)
+++ lldb/trunk/source/Host/common/Editline.cpp Thu Feb 27 13:48:13 2014
@@ -640,29 +640,40 @@ Editline::GetCharFromInputFileCallback (
     Editline *editline = GetClientData (e);
     if (editline && editline->m_got_eof == false)
     {
-        char ch = ::fgetc(editline->GetInputFile());
-        if (ch == '\x04')
+        while (1)
         {
-            // Only turn a CTRL+D into a EOF if we receive the
-            // CTRL+D an empty line, otherwise it will forward
-            // delete the character at the cursor
-            const LineInfo *line_info = ::el_line(e);
-            if (line_info != NULL &&
-                line_info->buffer == line_info->cursor &&
-                line_info->cursor == line_info->lastchar)
+            errno = 0;
+            char ch = ::fgetc(editline->GetInputFile());
+            if (ch == '\x04')
             {
-                ch = EOF;
+                // Only turn a CTRL+D into a EOF if we receive the
+                // CTRL+D an empty line, otherwise it will forward
+                // delete the character at the cursor
+                const LineInfo *line_info = ::el_line(e);
+                if (line_info != NULL &&
+                    line_info->buffer == line_info->cursor &&
+                    line_info->cursor == line_info->lastchar)
+                {
+                    ch = EOF;
+                    errno = 0;
+                }
+            }
+        
+            if (ch == EOF)
+            {
+                if (errno == EINTR)
+                    continue;
+                else
+                {
+                    editline->m_got_eof = true;
+                    break;
+                }
+            }
+            else
+            {
+                *c = ch;
+                return 1;
             }
-        }
-    
-        if (ch == EOF)
-        {
-            editline->m_got_eof = true;
-        }
-        else
-        {
-            *c = ch;
-            return 1;
         }
     }
     return 0;


_______________________________________________
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to