7

If you have ever tried highlighting text in a command prompt window while a script is running that is outputting text, you'll notice that it no longer outputs text.

My question is if the highlighting inside a cmd window simply prevents it from outputting text, but still allows the script to run, or if it halts the execution of the script while highlighted?

Regardless of the answer, it would also be nice to know why it does this? Both the reason and purpose would be great.

Thanks

Recessive
  • 1,780
  • 2
  • 14
  • 37
  • 3
    The script still executes; only the output is paused. The reason is simple: It can tell you're trying to select text, which would be hard to do if the text was scrolling due to new output being added. – Ken White Feb 11 '19 at 03:31

1 Answers1

10

This is done to allow you to make the selection. Otherwise, new output could scroll everything and you would end up not selecting what you wanted.

Only output is suspended. The program will continue executing, however if it uses unbuffered IO, or the buffer it uses is full, it will block on a write call until the selection is done.

P Varga
  • 19,174
  • 12
  • 70
  • 108