Fellow Monks:
I am starting a non-Perl process using Win32::Process and then trying to wait infinitely for the child to finish. In the meantime, the Perl parent process is checking the Windows clipboard to provide status messages to the user (this is a Tk app). (Therefore I can't use "system" which either waits or doesn't wait.)
If the parent sees that the clipboard is empty, it should fall thru to the $ProcessObj->Wait(INFINITE) statement, which it does, but that statement seems to have no effect. My Perl parent keeps processing and the child does too.
The same problem occurs if I comment out the entire clipboard stuff, so it appears to be strictly a problem with Win32::Process.
Here's the code:
use Tk;
use Win32::Clipboard;
use Win32::Process;
$::CLIP = Win32::Clipboard();
# lots of code here
Win32::Process::Create($ProcessObj,
"d:\\mwa\\perlpps\\mwebprep.exe",
"mwebprep $step",
0,
NORMAL_PRIORITY_CLASS,
".")
|| die Win32ProcessError();
my $emptytries = 0;
my $clip;
while (1)
{
$clip = Win32::Clipboard::GetText();
if ($clip)
{
$::progresstext->insert('end', $clip . "\n");
$::progresstext->yview('moveto', 100);
$::mainwin->update;
$::CLIP->Empty();
$emptytries = 0;
sleep(5);
}
else
{
$emptytries++;
last if ($emptytries >= 3);
sleep(1);
}
}
$ProcessObj->Wait(INFINITE);
# more code
Many thanks in advance for any advice!
Stephen
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.