Possible to create Process object for an existing process?
Is it possible to bind a Process object for an existing process? My goal is to be able to wait on an already running process on the s开发者_如何转开发ystem.
This is not possible using the standard java.lang.Process
class. The only thing I can think of is to write a script to do the waiting for your, and then invoke that via Runtime.exec
and wait on it (or use JNI).
The other obvious option is to have your script drop some evidence of it having finished (with no errors). The classic evidence would be some kind of file, or row in a database, which your Java application can spin on
UNIX systems won't allow the JVM to use the normal underlying system calls on a process that was is not a child of the JVM process. I think it's unlikely that they've created an alternative implementation.
So you'll probably have to do this some other, platform specific, way.
精彩评论