Delay console CPR timer once protocol has worked (#30674)
Delay console CPR timer once protocol has worked (#30674)

Getting the current cursor position involves writing a particular escape sequence to stdout and then reading/parsing the response.  In case the terminal doesn't support the sequence, we use `tcsetattr` to tell the terminal set set c_cc[MIN] to 0 and c_cc[VTIME] to 10; this makes it so that if no input is received within one second, we'll give up on reading the response.  If we didn't do this and no response came back, or if a faulty response came back such that we would otherwise just sit there waiting for something that would never come, the console could end up hanging until the user typed the expected sequence.

However, this timeout can cause problems when the terminal is separated by a slow network connection from the console logic, in which case the CPR can time out and the response can end up not only being echoed to the screen, but also interpreted as user input.

This change tracks whether we've ever received a successful CPR response. Until we have, it keeps using 0 for c_cc[MIN], i.e. the minimum number of chars we need to read, such that it relies on the timeout firing and we return when either we've read at least one byte or the timer fires.  Once we've successfully read a CPR response, for all future requests, we set c_cc[MIN] to 1.  With that, we'll still return once at least one byte is received, but the timer won't start until then, which helps avoid this issue with slow network connections.
ptoonen/corefx,shimingsg/corefx,shimingsg/corefx,wtgodbe/corefx,Jiayili1/corefx,BrennanConroy/corefx,ericstj/corefx,ViktorHofer/corefx,mmitche/corefx,ptoonen/corefx,ericstj/corefx,wtgodbe/corefx,wtgodbe/corefx,Jiayili1/corefx,shimingsg/corefx,ptoonen/corefx,ViktorHofer/corefx,shimingsg/corefx,mmitche/corefx,ericstj/corefx,wtgodbe/corefx,ptoonen/corefx,shimingsg/corefx,ericstj/corefx,ericstj/corefx,Jiayili1/corefx,Jiayili1/corefx,shimingsg/corefx,mmitche/corefx,ptoonen/corefx,mmitche/corefx,ViktorHofer/corefx,ptoonen/corefx,Jiayili1/corefx,ViktorHofer/corefx,Jiayili1/corefx,mmitche/corefx,ViktorHofer/corefx,Jiayili1/corefx,ViktorHofer/corefx,mmitche/corefx,shimingsg/corefx,ericstj/corefx,mmitche/corefx,wtgodbe/corefx,BrennanConroy/corefx,wtgodbe/corefx,ViktorHofer/corefx,BrennanConroy/corefx,ericstj/corefx,wtgodbe/corefx,ptoonen/corefx