though I've got to do some man page reading to fully understand this. I've never used any of the thread modules

A little explanation might help.

The core of the mechanism is here:

## Start the command connecting our output to its input ## (You might need to use open2/3() if you want to capture the output) my $pid = open CMD, '|-', $cmd or die $!; ## A shared var that captures whether the print succeeds ## If it does, the process went into an input state ## if it doesn't it ended (or was terminated) without entering an inpu +t state my $inInputState :shared = 0; ## Attempt to write to the process ## in a thread so we can do other things while it blocks. ## No newline so the process doesn't see it ## a series of spaces followed by backspaces ## which should be "cancelled out" by the line edit API ## 4096 chars to ensure it gets through pipe buffering async { $inInputState = 1 if printf CMD " \b"x2048; }->detach; ## A microsleep to ensure responsiveness whilst avoiding cpu burn ## until the process self terminates ## or we reach the timeout period ## or the print succeeds -- entered input state Win32::Sleep 10 until !kill 0, $pid or $timedOut = time() > $timeout or $inInputState

The rest is just mechanics.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re^3: Testing for a background process waiting for input (use a thread) by BrowserUk
in thread Testing for a background process waiting for input by SBECK

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.