How to read from the terminal "keystrokes buffer"?

Viewed 1658

Say that the ping command is running, and I type something on the terminal while ping is still running.

Now when ping terminates and bash gain back control, bash will print on the terminal what I typed while ping was running. This is a screenshot that shows what I mean:

enter image description here

How did bash get this information? I am sure it did not get it from stdin, because when I typed "I typed this while ping was running", I did not press Enter (and so stdin is empty).

So this data must have been stored in a "keystrokes buffer", and bash read from this buffer.

My question is, how does bash reads from this buffer (what function does it call...)?

3 Answers
Related