> -----Original Message----- > From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl- > win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik > Sent: Tuesday, August 23, 2011 2:08 PM > To: perl-win32-users@listserv.ActiveState.com > Subject: Help with Win32::Process::Create() > > I'm working on an app that periodically needs to execute outside > procedures. Ideally, I want to launch the outside procedure in "fire > and > forget" mode; that is, I do not want to wait for the outside process to > terminate. > > I ALREADY HAVE some code that does this (see below). My question is- is > there a way to periodically poll the outside process to determine if it > is still running? I've tried a few things already and none of them > work. > > ================= the code ================= > use strict; > use warnings; > use Win32::Process; > > # Parameters for the Win32::Process::Create function: > # > # Process This is an empty string that will receive > # a process ID used to address the child process. > # Returns a string that looks like this: > # "Win32::Process=SCALAR(0x235478)". > # > # fullPath The full path to the program including the > # program name and extension. Can be UNC. > # > # newArg The name of the program itself with an extension, > # but no path. Also, command line arguments go here. > # > # inheritHndls Should the child process inherit the parent's file > handles? > # > # flagsx OR'd combination of the flags listed above. > # > # dirx Startup directory for the child process. > # > my $process = ''; > my $dirx = '.'; > my $inheritHndls = 0; > my $newArg = 'notepad.exe'; > my $fullPath = "c:\\windows\\system32\\$newArg"; > my $flagsx = DETACHED_PROCESS | NORMAL_PRIORITY_CLASS; > > if (my $spawnhndl = Win32::Process::Create($process, $fullPath, > $newArg, > $inheritHndls, $flagsx, $dirx)) > { > my $pid = $process->GetProcessID(); > print "Child process returned PID: $pid\n"; > } > else > { > my $errormsg = Win32::FormatMessage(Win32::GetLastError()); > print "Failed to launch process $fullPath: $errormsg\n"; > } > _______________________________________________
Take a look at the GetExitCode method for Win32::Process. HTH, Ken _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs