millisa has asked for the wisdom of the Perl Monks concerning the following question:
Under Win2K, this should show the following after opening and closing notepad:my($exitcode,$junk,$process,$process2,$process3); use Win32::Process; #create a notepad process Win32::Process::Create( $process, "c:\\winnt\\system32\\notepad.exe", "", 0, NORMAL_PRIORITY_CLASS, '.', ) or die "Could not start process\n"; #get the processid $procid=$process->GetProcessID(); print "PROCID: $procid\n"; #open the procid and get the exit code if(Win32::Process::Open($process2,$procid,0)==1){ Win32::Process::Open($process2,$procid,0); $exit=$process2->GetExitCode( $exitcode ); print "EXIT for PROCID-$procid: $exit\n"; print "Enter to continue\n"; }else{ print "ProcessID $procid not running\n"; } $junk=<STDIN>; #ok, kill the process $process->Kill( $exitcode ); print "$procid Process Killed\n"; print "Enter to continue\n"; $junk=<STDIN>; #now get the procid and exit code again if(Win32::Process::Open($process3,$procid,0)==1){ Win32::Process::Open($process3,$procid,0); $exit=$process3->GetExitCode( $exitcode ); print "EXIT for PROCID-$procid: $exit\n"; }else{ print "ProcessID $procid not running\n"; } exit;
PROCID: 1016 EXIT for PROCID-1016: 1 Enter to continue 1016 Process Killed Enter to continue ProcessID 1016 not runningHowever, on my Win2k3 systems, it is doing the following:
PROCID: 1980 EXIT for PROCID-1980: 1 Enter to continue 1980 Process Killed Enter to continue EXIT for PROCID-1980: 1Even though it *is* properly killing the notepad processID, it still seems to think it is openable with the module.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Another method of tracking process state in Win32? Win32::Process slightly broken on Win2k3
by Anonymous Monk on Nov 26, 2003 at 04:46 UTC |