zer0stimulus
zer0stimulus

Reputation: 23606

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 system.

Upvotes: 2

Views: 720

Answers (2)

oxbow_lakes
oxbow_lakes

Reputation: 134270

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

Upvotes: 2

Darron
Darron

Reputation: 21628

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.

Upvotes: 0

Related Questions