Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Michael Grove - 13 Jun 2005 00:11 GMT
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
millerch - 13 Jun 2005 00:20 GMT
How about "kill -2 PID" ?

> hi,
>
[quoted text clipped - 13 lines]
>
> -mike
millerch - 13 Jun 2005 00:38 GMT
Sorry, that won't work under windows...
have you looked at
http://www.latenighthacking.com/projects/2003/sendSignal/ ?

You can call GenerateConsoleCtrlEvent, or write something to wrap around
it. But that will only send a ctrl-c to a process in the same group,
which presumably is ok as it started from the same console...

(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/ge
nerateconsolectrlevent.asp
)

Hope that helps!

> How about "kill -2 PID" ?
>
[quoted text clipped - 15 lines]
>>
>>-mike
Michael Grove - 14 Jun 2005 02:07 GMT
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

> Sorry, that won't work under windows...
> have you looked at
[quoted text clipped - 29 lines]
>>>
>>>-mike


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.