Java hangs even though shell script’s execution is completed

view story

http://www.linuxquestions.org – I'm trying to execute a script from within my java code. The execution of the script is over(it's pid is no more), but java is stuck on waitFor() method of the shell script process!. And yes, I'm reading output and error streams in 2 separate threads. Yes, they are being joined at the end(after waitFor()). The aspect which makes this question relevant to this forum is, if I put the following line in the shell script(at the top), everything seems to work fine. Code: exec 3>&1 > /tmp/some_log 2>&1 And no, interestingly enough, the script doesn't generate any output!. Zero c (HowTos)