in reply to Re^2: Testing for a background process waiting for input (use a thread)
in thread Testing for a background process waiting for input

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?

  • Comment on Re^3: Testing for a background process waiting for input (use a thread)
  • Download Code