• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Equivalent kill -n for process.destroy()

 
E Hill
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to emulate the functionality of a currently existing Java application, here applications and .jars run by creating a process and they are shutdown by process.destroy().

My problem is that the process that will be doing the killing will be run from the command line, or a separate java program, so the only method of killing the process is to find the PID from ps and then use the linux kill command to kill the processes. So what is the equivalent flag in kill to the process.destroy()?

Thanks
E. Hill
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E, welcome to Java Ranch!

I use -9 to make sure the process gets killed. Example to kill proccess with pid of 1234:

kill -9 1234
 
E Hill
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks for the reply, does java use the equivalent of -9 in its process destroy? Killing everything with no chance of running and cleanup scripts etc?

We have the example of Process.destroy() in the program source code, however we are unable to kill the processes from Java as we will be launching through the command line and will not be starting processes in Java. We dont want to be too heavy-handed if possible, so would prefer to only use -9 as a last resort.

Thanks
E.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic