javaunixsolarisprocess-monitoring

Monitor a process in java


I have java process which uses process builder and calls a perl script. The perl script internally calls a binary in background and i have its process id in that perl script.Now i can return this process id back to java.

So now I have the process id in java. I just want to monitor that process in java whether its running or whether its not running. How can i do this monitoring inside java. Probably i need java threads but i am a bit new to java.So could anybody please suggest some directions?


Solution

  • Perhaps the easiest way is to check the /proc filesystem

    If process 1234 exists, there's a corresponding file entry /proc/1234.