gracefully terminate a JVM on windows if can't ctrl-c shell

M

Michael Grove

hi,

if i start a JVM on windows from one shell (or process), is there a way to
send the equivalent of a ctrl-c to the JVM from another shell or process?
on unix a regular kill gracefully terminates the JVM (shutdown hooks
invoked). on windows, unless i have access to the shell that started the
JVM, i'm not sure how to gracefully stop the JVM. i believe if i started
the JVM through JNI i could use JNI to stop the JVM gracefully (think that's
how JavaService does it) but i need to be able to stop a JVM started by
another process that invokes java.exe directly. i'm hoping i can write a
program that, given the JVM PID, sends a ctrl-c equivalent to the JVM.

ideas? didn't see this covered in a google search, sorry if i missed it.

thanks.

-mike
 
M

Michael Grove

thanks for the link. i was able to modify the source to SendSignal,
replacing every CTRL_BREAK_EVENT with CTRL_C_EVENT, and the program does
what i want. fairly complex - you have to inject a thread into the JVM
process, then send it the CTRL_C_EVENT - but it's the only solution i'm
aware of right now.

thanks again.

-mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top