• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I handle a subprocess?  RSS feed

 
David Wong
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the topic, I attempt to use ProcessBuilder to handle a subprocess, finally it works.

But I do wanna more feature of the subprocess, for instance, the time of subprocess running, the memory a subprocess consumed. If the running time or consumed memory of this subprocess exceeds the range that one customized, then destroy it immediately.

Is that possible, or else only jni can do it? thanks in advance.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One option is to use another process (started in another thread). This other process, either vmstat or tasklist, depending on the OS, can be called constantly to get a read on the first process. If the resource limits are violated, it can inform the first thread, which can kill the process.

Henry
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Henry,

Sorry for my ignorance on this, can you describe a little more or suggest me a good URL on how to do it.

Ananth Chellathurai
 
Henry Wong
author
Sheriff
Posts: 23295
125
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 Ananth Chellathurai:
Sorry for my ignorance on this, can you describe a little more or suggest me a good URL on how to do it.

Ananth Chellathurai


A little more of which? vmstat or tasklist? Which OS are you using -- Windows or unix?

Henry
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before you even think of going near Process or ProcessBuilder you need to find the classic article by Michael Daconta: here. RpocessBuilder makes it a bit easier, but the principals in Daconta are unchanged.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!