• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

runtime exec leaving <defunct> processes in unix

I'm calling runtime.exec to call a .sh script in unix.. this is done in a loop..  i am seeing a <defunct> proceess created in unix every iteration!  this will not do..  any idea how to have runtime.exec clean up after istelf?  

the .sh script is only checking to see in another process is running..  ( ps -a | mlcserv | wc -l )
0
xjeffk
Asked:
xjeffk
  • 2
  • 2
1 Solution
 
yorenCommented:
Try Process.waitFor() and see if that helps.
0
 
xjeffkAuthor Commented:
Yoren - that seems to work!  how does it have a handle to the thread, but destroy does nothing?
0
 
yorenCommented:
xjeffk,

Glad it worked for you. You had the right thinking when you said "clean up after itself." The issue is that many versions (maybe all?) of UNIX don't try to clean up child processes until the parent specifically waits for them to complete. If you want to kill a process and not leave a <defunct> child, you can try destroy() followed by waitFor() (I haven't tried this but it should work).

Leave another comment if you have more related questions.

Yuval
0
 
xjeffkAuthor Commented:
indeed.   it's solaris, and the waitFor did it..  just calling destroy without waitFor did not..

well, thanks..
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now