Interactive Shell now requires poll instead of just ReadAll?

I have some code written in Xojo 2014 that I’m working on finally updating to run in Xojo 2019.
The code includes this snippet of an interactive shell (sh2):

If Not sh2.IsRunning Then
    sh2.Execute "/bin/sh"
End If
Do
    buffer = sh2.ReadAll
    i = InStr(buffer,"$")
Loop Until i <> 0
sh2.WriteLine "su -m " + username

It used to be that would run /bin/sh, wait for the prompt to return and then switch the user.

Now for some reason, sh2.readAll isn’t returning anything and that goes into a permanent loop.

If I add sh2.poll before buffer = sh2.ReadAll I actually get the prompt quickly.

Did this change in a recent version of Xojo? Should I have always been doing sh2.poll? It seems like the documentation says sh2.ReadAll reads the contents without having to do a .poll

You should always have been using Poll. You apparently got lucky before and got the response right away. It could be that the shell is returning sooner now.

The documentation reference to ReadAll assumes you have let the event loop run and not tied it up in a tight loop. If you allow the event loop to run, it polls the shell for you. If you block the event loop with your own loop, you must poll the shell yourself.

Thanks Tim, that’s what I figured, just wanted to make sure before I go through all the code.