Hi

is there a more elegant way to achieve the following on windows?

perl -e "$|=1;for(1..100) { sleep 1;  warn time; print time,qq{\n} }" 2>&1 | perl -ne "$|=1;print"

This first script is printing time every second to STDOUT and STDERR.

If the output is connected to a Windows cmd.exe and any text was selected with the mouse, than the output will not only stop but the script will freeze and only continue after the selection was finished!

D:>perl -e "$|=1;for(1..100) { sleep 1; warn time; print time,qq{\n} +}" 1530361604 at -e line 1. 1530361604 1530361605 at -e line 1. 1530361605 # selecting text for some se +conds 1530361606 at -e line 1. # output resumes,last buffer +ed line 1530361622 # after freeze 1530361623 at -e line 1. 1530361623 1530361624 at -e line 1. 1530361624 1530361625 at -e line 1. 1530361625 Terminating on signal SIGINT(2)

( update for clarity: my problems is not that the output stops, but that the complete script stops running in the background.)

The behaviour in a linux terminal is different (much saner), the output might stop but the script will continue running in the background and the buffered output will appear after the selection.

My workaround is now piping the STDOUT and STDERR to a second Perl script which does the buffering without blocking the main script, but is not overly elegant...

Background information is that our provider changed the windows version and activated "QuickEdit mode" for consoles on default.

Now my colleagues are surprised to find out that their batch jobs freeze whenever someone does a simple click into a window which will "quickly" cause a selection ...

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

PS: I'd rather prefer running the scripts with wperl and directing STDOUT and STDERR to a file. If a live display is needed I'd use a tail -f approach, like with powershells get-content File -wait . Alas changing old working patterns in a team isn't easy ...

PPS: deactivating quickEdit in the registry (which isn't trivial for political reasons) doesn't solve the underlying issue, since a text selection could be initiated anyway.


In reply to [windows] Non-blockable output to cmd console during text selection? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.