Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^2: Killing a Win32 process, a return value ? (bugs)by tye (Sage) |
on Mar 03, 2007 at 03:36 UTC ( [id://603022]=note: print w/replies, xml ) | Need Help?? |
The documentation is inaccurate and the code is buggy. From http://search.cpan.org/src/JDB/libwin32-0.26/Process/Process.xs:
So, RETVAL isn't initialized so if OpenProcess() fails, RETVAL will be random garbage from the stack (some "large number", as observed, or sometimes 0 or 1, unfortunately, I guess -- unless the "arbitrary" observation is inaccurate and it is actually a standard Win32 marker value like 0xCCCCCCCC). If OpenProcess() succeeds, then RETVAL will say whether or not TerminateProcess() was successful or not. And exitcode is not an output parameter so it isn't set to anything. It specifies what exit code the terminated process will use (as documented in the Win32 SDK). Luckily, both OpenProcess() and TerminateProcess() call SetLastError() (Win32 SDK again) so you can check $^E to see if they failed (if you do it fast enough). For example:
But someone should really fix the docs and code for this module, especially since it leaks a process handle if TerminateProcess() fails. - tye
In Section
Seekers of Perl Wisdom
|
|