[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

runtime exec leaving <defunct> processes in unix

Posted on 2002-04-26
4
Medium Priority
?
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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 second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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:
Suggested Courses

656 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