Solved

runtime exec leaving <defunct> processes in unix

Posted on 2002-04-26
4
332 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now