in reply to Re^2: control-C to "jumpstart" windows process
in thread control-C to "jumpstart" windows process

If you are printing to STDOUT without having turned off the buffering, then the program will continue producing output and will not be blocked until the buffer has filled.

If the process completes before the buffer fills, then clearing the mark or select state will allow the ouput to finish though the process may have finished some time earlier.

The output will appear contiguous in both cases because of the buffering. No output is discarded, it is simply buffered and displayed once the freeze thaws.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^3: control-C to "jumpstart" windows process

Replies are listed 'Best First'.
Re^4: control-C to "jumpstart" windows process (line)
by tye (Sage) on Oct 18, 2006 at 16:25 UTC

    Note that output to STDOUT defaults to "line-buffered" mode (except on older versions of Win32 Perl where the default was unbuffered), so this would only apply to a single line of output (based on "\n", not a single row of the terminal window).

    - tye        

      Right. I often added debug out using printf "\r%d\t", $loopVariable unless $loopVariable % 1000, but if STDOUT is buffered, then you have to wait for the buffer to fill before you "see" the first output, and then it increments in leaps and bounds. You can see this with:

      c:\test>perl -lwe" Win32::Sleep( 10 ),printf qq[\r%d\t], $_ for 1 .. 1 +e6"

      Which appears to display (overlaid of course):

      841 1550 2232 2915 ...

      Update: Once you get to 4-digit numbers, the interval is 682. With 4-digits, "\r" & "\t", that is 6 * 682 = 4092. A 4kb buffer.

      Whereas if you disable the buffering

      c:\test>perl -lwe"$|=1;Win32::Sleep( 10 ),printf qq[\r%d\t], $_ for 1 +.. 1e6"

      You see the number increment from 1, quickly and continuously.

      I guess the buffering doesn't consider "\r" as a line ending -- probably rightly. It is useful for monitoring the progress of long running processes. Leaving the buffering enabled means that the IO has a negligable effect upon the speed of the code, and has the beneficial side effect that I can 'pause' and 'resume' the long running process by using the left and right mouse buttons alternately. Mouse equivalent of ^S.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.