Hi Michael,
You may want to look at the Win32::Job module. As long as your vendor programs
don't get started with the "break away from job"
attribute you should be able to check the status of all processes started
inside the job object. Maybe some combination of the
watch() and status() methods of the watch object will do what you want.
Cheers,
-Jan
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Michael Cohen
Sent: Wednesday, March 11, 2009 4:26 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Win32::Process Help Needed - Main Process Exits While Children Run
I have a piece of code that has been running for a number of years, until now.
My vendor changed the way they created a program,
and that new program exits before its children's processes are finished. In
the past, the following "snippette" has worked fine for
me:
my $progFullPath = "c:\\temp\\foobar.exe";# Not the real program
my $commandLine = "foobar opt1 opt2"; # Again, just an example
my $ProcessObj;
Win32::Process::Create($ProcessObj,
$progFullPath,
$commandLine,
0,
NORMAL_PRIORITY_CLASS,
".")|| die print Win32::FormatMessage( Win32::GetLastError() );
while (!($done)) {
$done = 1 if ($ProcessObj->Wait(100));
$main->update; # TK update
}
As noted above, the "Wait(100)" would work fine if the parent program does not
exit prematurely. However, now that that is no
longer true:
a) How do I determine all of the children processes on Windows (specifically
XP at this point)?
b) How do I wait until all children processes are finished?
I have been searching the web for various options for several hours, and just
cannot come up with one at this point. If anyone has
any suggestions, pointers, solutions, etc., I would be most appreciative of
your help.
Regards,
Michael Cohen
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs