<div dir="ltr">Hello Abid,<div><br></div><div>Thanks again for the fix :)<br></div><div>As far as I know this needed only on OSX and it isn't required on other platforms. But after it was committed 'lldb-mi --interpreter' began to load cpu over 100%!! It's very bad on my side. And as I understood it happened on Linux too. Of course it helped with hangs on OSX, but it made worse for Linux (and OSX). You said that 'select' patch increases time to run test many times, but I didn't face with it on OSX (although I think 'select' shouldn't affect it). I believe that it is necessary to revert 'ioctl' patch (to avoid overheads of CPU) and apply 'select' patch to OSX only (by using #ifdef __APPLE__ or by creating separate file).</div><div><br></div><div>I can create patch for it if you agree.</div><div><br></div><div>Thanks,</div><div>Ilia</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 4, 2014 at 2:04 PM, Abid, Hafiz <span dir="ltr"><<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Please send them. I will try.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Abid<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 04 December 2014 11:02</span></p><div><div class="h5"><br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.<u></u><u></u></div></div><p></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Abid,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">Thank you.<u></u><u></u></p>
<div>
<p class="MsoNormal">I have a few more patches and possible I'll send some of them today. Could you review them too?<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Ilia<u></u><u></u></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Thu, Dec 4, 2014 at 1:53 PM, Abid, Hafiz <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">I tried to remove setbuf() yesterday and it didn't affect, so I think it is not needed. Could you remove code related to setbuf() from my patch yourself?<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Ok I will remove and then commit the patch. If you intend to contribute more patches. I would be
 good to get commit access.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Abid</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 04 December 2014 10:41</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.<u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hi Abid,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">> <span style="font-size:11.5pt;font-family:"Calibri","sans-serif";color:#1f497d"> It is now returning false when ioctl fails</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I think that it's right, because status is unavailable.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">> <span style="font-size:11.5pt;font-family:"Calibri","sans-serif";color:#1f497d">Regarding your question about setbuf, I thought that setting it to null makes ioctl type function
 to return when some input is available and not wait for the new line character</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I realized that setbuf is not needed. As you said, it makes ioctl type function to return when some input is available and not wait for the new line character, but in canonical
 mode, you don't get control back until the new line character had typed.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">> <span style="font-size:11.5pt;font-family:"Calibri","sans-serif";color:#1f497d">Can you try on OSX after removing the setbuf call</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I tried to remove setbuf() yesterday and it didn't affect, so I think it is not needed. Could you remove code related to setbuf() from my patch yourself?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Ilia<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Thu, Dec 4, 2014 at 1:17 PM, Abid, Hafiz <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Ilia,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks for the patch. It looks much cleaner. I was also not sure how tcgetattr type functions were
 helping with the original fix. Regarding your patch, I only have one comment. It is now returning false when ioctl fails. It can result in lldb-mi quitting. Previously this function was always returning true. I don’t think this is a big deal though.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Regarding your question about setbuf, I thought that setting it to null makes ioctl type function
 to return when some input is available and not wait for the new line character. I may be wrong here too. Can you try on OSX after removing the setbuf call. Does that change the behaviour in any way. Because I cannot see any noticeable difference on Linux.
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Abid</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 03 December 2014 16:17</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.<u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hi Abid,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Sorry for remarks, but there is a one problem with "ioctl" patch: it turns off canonical mode so we can't modify commands on input line correctly :(.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Also I added error checks and moved "setbuf(stdin, NULL)" into Initialize function to avoid ugly in-place initialization using static variable (but, if be honest I don't know why
 we need to disable bufferization before "ioctl" call).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I prepared new patch. Review it please.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Ilia<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Wed, Dec 3, 2014 at 3:52 PM, Ilia K <<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>> wrote:<u></u><u></u></p>
<p>Thank you<u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On 3 Dec 2014 15:50, "Abid, Hafiz" <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks for catching this. I have removed the extra changes in r223227.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Abid</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 03 December 2014 12:40<br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> RE: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<p>Yes. "select" patch requires extra handling on exit.<u></u><u></u></p>
<p>Thanks, <br>
Ilia<u></u><u></u></p>
<div>
<p class="MsoNormal">On 3 Dec 2014 15:37, "Abid, Hafiz" <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">You mean that just the change in ‘InputAvailable’ was needed? Rest of the changes were required with
 ‘select’.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Abid</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 03 December 2014 10:59<br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hello Abid,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">Thanks for commit :)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">But "ioctl" patch requires less changes than "select" version of this patch. Could you commit another patch to revert all unnecessary changes?<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Ilia<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Wed, Dec 3, 2014 at 1:23 PM, Hafiz Abid Qadeer <<a href="mailto:hafiz_abid@mentor.com" target="_blank">hafiz_abid@mentor.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">Author: abidh<br>
Date: Wed Dec  3 04:23:06 2014<br>
New Revision: 223222<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223222&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=223222&view=rev</a><br>
Log:<br>
Fix a hang on OSX while executing -exec-run.<br>
Now we wait for input to become available before blocking in fgets.<br>
More details on problem can be found in<br>
<a href="http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20141201/014290.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20141201/014290.html</a><br>
<br>
Patch from <a href="mailto:dawn@burble.org" target="_blank">dawn@burble.org</a>.<br>
<br>
<br>
Modified:<br>
    lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp<br>
    lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h<br>
    lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp<br>
    lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h<br>
    lldb/trunk/tools/lldb-mi/MIDriver.cpp<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp (original)<br>
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp Wed Dec  3 04:23:06 2014<br>
@@ -434,3 +434,16 @@ CMICmnStreamStdin::SetOSStdinHandler(IOS<br>
<br>
     return MIstatus::success;<br>
 }<br>
+<br>
+//++ ------------------------------------------------------------------------------------<br>
+// Details: Do some actions before exiting.<br>
+// Type:    Method.<br>
+// Args:    None.<br>
+// Return:  None.<br>
+// Throws:  None.<br>
+//--<br>
+void<br>
+CMICmnStreamStdin::OnExitHandler(void)<br>
+{<br>
+    m_pStdinReadHandler->InterruptReadLine();<br>
+}<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h (original)<br>
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h Wed Dec  3 04:23:06 2014<br>
@@ -66,6 +66,7 @@ class CMICmnStreamStdin : public CMICmnB<br>
       public:<br>
         virtual bool InputAvailable(bool &vwbAvail) = 0;<br>
         virtual const MIchar *ReadLine(CMIUtilString &vwErrMsg) = 0;<br>
+        virtual void InterruptReadLine(void){};<br>
<br>
         /* dtor */ virtual ~IOSStdinHandler(void){};<br>
     };<br>
@@ -82,6 +83,7 @@ class CMICmnStreamStdin : public CMICmnB<br>
     void SetCtrlCHit(void);<br>
     bool SetVisitor(IStreamStdin &vrVisitor);<br>
     bool SetOSStdinHandler(IOSStdinHandler &vrHandler);<br>
+    void OnExitHandler(void);<br>
<br>
     // Overridden:<br>
   public:<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp (original)<br>
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp Wed Dec  3 04:23:06 2014<br>
@@ -22,7 +22,9 @@<br>
 // Third Party Headers:<br>
 #if !defined(_MSC_VER)<br>
 #include <sys/select.h><br>
+#include <unistd.h><br>
 #include <termios.h><br>
+#include <sys/ioctl.h><br>
 #endif              // !defined( _MSC_VER )<br>
 #include <string.h> // For std::strerror()<br>
<br>
@@ -153,30 +155,29 @@ CMICmnStreamStdinLinux::Shutdown(void)<br>
 bool<br>
 CMICmnStreamStdinLinux::InputAvailable(bool &vwbAvail)<br>
 {<br>
-    /* AD: Not used ATM but could come in handy just in case we need to do<br>
-           this, poll for input<br>
-<br>
-            static const int STDIN = 0;<br>
-        static bool bInitialized = false;<br>
-<br>
-        if( !bInitialized )<br>
-            {<br>
-            // Use termios to turn off line buffering<br>
-            ::termios term;<br>
-            ::tcgetattr( STDIN, &term );<br>
-            ::term.c_lflag &= ~ICANON;<br>
-            ::tcsetattr( STDIN, TCSANOW, &term );<br>
-            ::setbuf( stdin, NULL );<br>
-            bInitialized = true;<br>
-        }<br>
-<br>
-        int nBytesWaiting;<br>
-        ::ioctl( STDIN, FIONREAD, &nBytesWaiting );<br>
-        vwbAvail = (nBytesWaiting > 0);<br>
-<br>
-            return MIstatus::success;<br>
-    */<br>
-<br>
+#if !defined(_WIN32)<br>
+    // The code below is needed on OSX where lldb-mi hangs when doing -exec-run.<br>
+    // The hang seems to come from calling fgets and fileno from different thread.<br>
+    // Although this problem was not observed on Linux.<br>
+    // A solution based on 'select' was also proposed but it seems to slow things down<br>
+    // a lot.<br>
+    static bool bInitialized = false;<br>
+<br>
+    if (!bInitialized)<br>
+    {<br>
+        // Use termios to turn off line buffering<br>
+        ::termios term;<br>
+        ::tcgetattr(STDIN_FILENO, &term);<br>
+        term.c_lflag &= ~ICANON;<br>
+        ::tcsetattr(STDIN_FILENO, TCSANOW, &term);<br>
+        ::setbuf(stdin, NULL);<br>
+        bInitialized = true;<br>
+    }<br>
+<br>
+    int nBytesWaiting;<br>
+    ::ioctl(STDIN_FILENO, FIONREAD, &nBytesWaiting);<br>
+    vwbAvail = (nBytesWaiting > 0);<br>
+#endif<br>
     return MIstatus::success;<br>
 }<br>
<br>
@@ -213,3 +214,16 @@ CMICmnStreamStdinLinux::ReadLine(CMIUtil<br>
<br>
     return pText;<br>
 }<br>
+<br>
+//++ ------------------------------------------------------------------------------------<br>
+// Details: Interrupt current and prevent new ReadLine operations.<br>
+// Type:    Method.<br>
+// Args:    None.<br>
+// Return:  None.<br>
+// Throws:  None.<br>
+//--<br>
+void<br>
+CMICmnStreamStdinLinux::InterruptReadLine(void)<br>
+{<br>
+    fclose(stdin);<br>
+}<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h (original)<br>
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h Wed Dec  3 04:23:06 2014<br>
@@ -51,6 +51,7 @@ class CMICmnStreamStdinLinux : public CM<br>
     // From CMICmnStreamStdin::IOSpecificReadStreamStdin<br>
     virtual bool InputAvailable(bool &vwbAvail);<br>
     virtual const MIchar *ReadLine(CMIUtilString &vwErrMsg);<br>
+    virtual void InterruptReadLine(void);<br>
<br>
     // Methods:<br>
   private:<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MIDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIDriver.cpp?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIDriver.cpp?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MIDriver.cpp (original)<br>
+++ lldb/trunk/tools/lldb-mi/MIDriver.cpp Wed Dec  3 04:23:06 2014<br>
@@ -1075,6 +1075,7 @@ CMIDriver::SetExitApplicationFlag(const<br>
     {<br>
         CMIUtilThreadLock lock(m_threadMutex);<br>
         m_bExitApp = true;<br>
+        m_rStdin.OnExitHandler();<br>
         return;<br>
     }<br>
<br>
@@ -1089,6 +1090,7 @@ CMIDriver::SetExitApplicationFlag(const<br>
     }<br>
<br>
     m_bExitApp = true;<br>
+    m_rStdin.OnExitHandler();<br>
 }<br>
<br>
 //++ ------------------------------------------------------------------------------------<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div>