Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.

In reply to Re: Killing a Win32 process, a return value ? by BrowserUk
in thread Killing a Win32 process, a return value ? by abachus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found