Will KillProcess return true on success? what this exit code means will that tells me it was a success? How can I check with an exitcode or returnCode and make sure a process actually killed?
The process cannot prevent it.
Check $^E for the reason it failed.
It is the value that will be returned to any process that calls GetExitProcess() after it has been killed.
Follow the KillProcess() call with a call to the Wait() method.
When that returns the process is actually dead,
Pass an unusual exitcode (eg. not 1 or 0 or -1; say 13579 or your favorite sub 2**16 prime number).
And then call the GetExitCode() method and compare. Not that you would be able to do anything about it if it wasn't.
If you have the appropriate permissions to kill the process; the single call to KillProcess() will kill it. And if you do not; retrying won't help.
Calling the Wait() method will ensure that it has actually died before your program continues; but be aware that if -- for example -- the process had just initiated a synchronous read request -- say a blocking tcp read -- to device or server that was slow, broken or non-existent, then you might have to wait quite some time before the process actually goes away and the Wait() completes. (For example: many tcp timeouts default to 900 seconds; some default DB server timeouts are even longer!)
The bottom line is: for most purposes, simply getting a non-zero return code from KillProcess() is enough to allow you to proceed.
In reply to Re: Kill a process in perl windows and proceed only if it killed the process
by BrowserUk
in thread Kill a process in perl windows and proceed only if it killed the process
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |