• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Killing a Process ..Please Help

 
SBELUR BELUR
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

This is the situation.
From my Python script I start a Java Process which starts rmiregistry at some port

Now I am interested in Killing the rmiregistry process .
So i start another Python script which runs another Java Program ....
BUT now i am not sure how to kill the process ?

THIS IS MY QUESTION

Basically 2 jvms are run . IN one jvm i have process handle.
BUT how do i kill process from different JVM

If this is not possible i would lilke to know how to the below

in java

1> HOW DO I KILL A PROCESS RUNNING AT SOME PORT (In general)
(Can be started frrom different JVM ?)
2> Also is it possible to get PID of process from Java
 
Amit Bathla
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u can kill a process using (kill pid) command in linux or unix
but for this u have to know the pid of ur process this will be different every time u call ur prog.
in windows who knows ???
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using RMI already, why not just make a remote method called "shutdown()" or something to de-register from the rmiregistry and call System.exit()?

This is actually a lot easier to do than kill the process. To kill a process you have to code special ways on every platform you want to run on. Another problem is finding the exact process to kill - most JVMs name *every* java process running "java" - you have to run something internal to the program you want to kill to get the process id. This requires interacting with native code (again for each platform you want it to run on).

Another nice point to using a remote method to do this is that you can do a 'nice' shutdown and wait for all remote connections to close before actually shutting down. If you kill the process, it just shuts down right then, no matter what else is going on.
 
Henry Wong
author
Marshal
Pie
Posts: 21024
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amit bathla:
u can kill a process using (kill pid) command in linux or unix
but for this u have to know the pid of ur process this will be different every time u call ur prog.
in windows who knows ???


The Windows equivalent is "taskkill /pid processID".

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic