Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Killing a Win32 process, a return value ?

by BrowserUk (Patriarch)
on Mar 03, 2007 at 03:53 UTC ( [id://603024]=note: print w/replies, xml ) Need Help??


in reply to Killing a Win32 process, a return value ?

Basically, you found a bug in the implementation:

BOOL KillProcess(pid, exitcode) DWORD pid unsigned int exitcode CODE: { HANDLE ph = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); if (ph) { RETVAL = TerminateProcess(ph, exitcode); if (RETVAL) CloseHandle(ph); } } OUTPUT: RETVAL

Or maybe several bugs.

  1. If your perl process is not running with sufficient priviledges to open the target process PROCESS_ALL_ACCESS, then RETVAL is never being (visibly) set and you are getting whatever value it is initialised to by XSUBPP (if any, the docs are less than clear about this), or some random value in the ram it inherits.
  2. If OpenProcess() succeeds, then you get the return value of TerminateProcess(), which is non-zero for success, or zero for failure in which case calling GetLastError() should tell you why it failed.

It's possible that when it fails, the arbitrarily large number you are getting is the OS failure code. It would be worth comparing it against the numeric realisation of $^E.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://603024]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (None)
    As of 2024-04-25 01:03 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found