I encountered a problem the other day while running multiple
tty sessions in separate terminal windows. I was running a expensive disk access command and was waiting for it to return. Meanwhile I was working in another
tty session in a separate window in my graphical desktop environment.
Inadvertently I focused the terminal that was running the disk access command (basically a
cp command) and typed the following into the terminal thinking I was going to enter it into my other window:
Based on this question I knew that the data was now sitting in the
STDIN data stream buffer waiting to be run immediately upon the return of the first
cp command. And as you know I just told the command to run again :/ .
Since I had some time (this command was taking > 30 mins to return), is there a way I could have flushed these characters out of the
STDIN buffer of that
tty before bash reran the process it was finishing?
Or is there another way, other than trying to flush data out of the file stream buffer of another bash instance, that I could avoid having the data evaluated as soon as the process that I was waiting on finished?