Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

handling Java child process execution

 
amit pandit
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am executing a shell script using java program on unix platform.
I am using Runtime.exec(shell_script_name) method to execute it.
A shell script uses prstat command & it gives well formated output to my java program.
But, the problem is that the prstat command doesn't get killed by unix os.
so that , when ever I execute the script each time a new instance of prstat is seen as a new process using ps -fu command. & this prstat process seen even when java program is stopped.

please, help me so that prstat command execution should get stopped just after script execution finished.

Thanks

Amit Pandit
 
Vilmantas Baranauskas
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your shell script launch "prstat" in the background?

If not, have you tried to invoke Process.destroy() after you've got necessary outout?
 
Vilmantas Baranauskas
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, what happens if you invoke the same shell script manually?
 
amit pandit
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have tried with destory() but id doen't help.

When i run script manually it runs fine. and prstat command (process) is not seen after execution of script.

Thanks

Amit Pandit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic