Solved

runtime exec leaving <defunct> processes in unix

Posted on 2002-04-26
4
338 Views
Last Modified: 2012-05-04
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
Comment
Question by:xjeffk
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:yoren
ID: 6972157
Try Process.waitFor() and see if that helps.
0
 

Author Comment

by:xjeffk
ID: 6973202
Yoren - that seems to work!  how does it have a handle to the thread, but destroy does nothing?
0
 
LVL 7

Accepted Solution

by:
yoren earned 100 total points
ID: 6974356
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
 

Author Comment

by:xjeffk
ID: 6975292
indeed.   it's solaris, and the waitFor did it..  just calling destroy without waitFor did not..

well, thanks..
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question