mojoshaneman has asked for the wisdom of the Perl Monks concerning the following question:

On a Windows system, I want to send a <ctrl><break> to a Java process to get a Java stack trace. How do I do this in Perl? I tried kill with no luck. kill("QUIT", $pid);

Replies are listed 'Best First'.
Re: Sending <ctrl><break> to java
by ikegami (Patriarch) on Apr 27, 2007 at 02:34 UTC

    Windows doesn't have signals. If some usage of kill does what you want, it would be a very special emulation. It would surely be better to call the underlying system call more directly. Win32::Console's GenerateCtrlEvent does just that.

    Note that GenerateCtrlEvent can be called as a static method: Win32::Console->GenerateCtrlEvent(...);. You do not need to create a Win32::Console object.

      Thanks for the replies.

      I tried:

      kill('ABRT',$pid);
      kill('BREAK',$pid);

      Win32::Console->GenerateCtrlEvent(CTRL_BREAK_EVENT, $pid);

      No dice. Any other ideas?
Re: Sending <ctrl><break> to java
by sgifford (Prior) on Apr 27, 2007 at 02:34 UTC
    Three ideas:
    • Try kill('ABRT',$pid). Traditionally ABRT has caused core dumps, so maybe on Java you'll get a stack dump.
    • Try kill('BREAK',$pid). Perl handles CTRL-BREAK in a $SIG{BREAK} handler, IIRC, so maybe you can send a break signal this way?
    • Win32::Console claims to have code to send break signals, though I haven't tried it.
    Good luck! Hopefully one of these will help!