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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |