• 
      

    Fix and bullet-proof terminal querying for background colors.

    Review Request #14249 — Created Nov. 15, 2024 and submitted

    Information

    rbinstall
    master

    Reviewers

    When querying the terminal for background colors, an assumption was made
    that we'd always have input. We'd block forever with the assumption that
    we had data to read, and this wasn't always the case. It'd then require
    mashing on keys until the read buffer was filled, if the terminal and
    pipes indeed even fed the keyboard input to the process.

    We now put stdin in non-blocking mode and read so long as there's data
    to read, until we hit a result with a terminator, fill up the buffer, or
    time out.

    Along with this, we had a bug where we were looking for the wrong
    terminator, which contributed to this blocking issue. The correct
    terminator is now used.

    Reproduced on a system that was blocking on startup and then interfering
    with reading stdin. Verified this fixed the issue I was able to
    reproduce.

    Summary ID
    Fix and bullet-proof terminal querying for background colors.
    When querying the terminal for background colors, an assumption was made that we'd always have input. We'd block forever with the assumption that we had data to read, and this wasn't always the case. It'd then require mashing on keys until the read buffer was filled, if the terminal and pipes indeed even fed the keyboard input to the process. We now put stdin in non-blocking mode and read so long as there's data to read, until we hit a result with a terminator, fill up the buffer, or time out. Along with this, we had a bug where we were looking for the wrong terminator, which contributed to this blocking issue. The correct terminator is now used.
    756ee66f32efaa00cc54c7165187415732b7412b
    maubin
    1. Ship It!
    2. 
        
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (0374fb6)