<div dir="ltr">Hi,<br><br>I have attached a patch which addresses 3 related race conditions that cause the command line (lldb) prompt to get displayed inappropriately and make it appear it is not working correctly. This issue can be seen on linux and FreeBSD. I can also artificailly induce the problem on OSX.<br>
<br>The issue happens when the command handler (in the main thread) issues a command such as run, step or continue. After the command finishes initiating its action, it returns up the call stack and goes back into the main command loop waiting for user input. Simultaneously, as the inferior process starts up, the MonitorChildProcess thread picks up the change and posts to the PrivateEvent thread. HandePrivateEvent() then calls PushProcessIOHandler() which will disable the command IO handler and give the inferior control of the TTY. To observe this on OSX, put a <br>
<br>usleep(100);<br><br>immediately prior the PushProcessIOHandler() in HandlePrivateEvent.<br><br><br>My proposed solution is that after a 'run', 'step', or 'continue' command, insert a synchronization point and wait until HandlePrivateEvent knows the inferior process is running and has pushed the IO handler. One context switch (<100us) is usually all the time it takes on my machine. As an additional safety, I have a timeout (currently 1ms) so it will never hang the main thread.<br>
<br>Any thoughts, or suggestions would be appreciated.<br><br>Regards,<br>Shawn.<br></div>