General
cancel
Showing results for 
Search instead for 
Did you mean: 

Process.destroy kills outer shell when killing inner

Peter Suggitt
Occasional Contributor

Process.destroy kills outer shell when killing inner

Hi

I have a nice little problem when I use the Runtime.exec() method. If I have a running C++ binary in a Process object and I want to kill it I issue a destroy at the Process object and the process picks up whatever signals are sent and it it terminates correctly.

If I then use the same code to execute a shell script then the whole program terminates after picking up the sent signal.

The script I am using is a csh script:
#!/bin/csh -f
while (1)
echo help
sleep 10
done
# this will not terminate until I need it to

I am running this on Red Hat Linux and starting the process from a csh .. I have no idea why this is so .. has anyone else come across this before?

When I run this with verbose I also get the following before it all terminates (the log4j comment is just from a shutdownhook):
...
[Loaded sun.misc.Signal$1 from /sbcimp/run/tp/sun/jre/v1.4.2_04/lib/rt.jar]
Shutting down log4j processses
[Loaded java.util.Vector$1 from /sbcimp/run/tp/sun/jre/v1.4.2_04/lib/rt.jar]
[Loaded org.apache.log4j.helpers.NullEnumeration]
suggitpe./home/suggitpe/test/MEMPHIS/TAX_TEST/bin.xldn1081dap -->
3 REPLIES
Bojan Nemec
Honored Contributor

Re: Process.destroy kills outer shell when killing inner

Hi Peter,

Got some time to write some test programs. I could not reproduce yours error. The program works just fine. I used yours code for the script (replacing done with end!). I have tested on RedHat 9 and yours same version of Java (1.4.2_04-b05).

Bojan
Bojan Nemec
Honored Contributor

Re: Process.destroy kills outer shell when killing inner

Sorry,

After reading yours post in thread
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=717270
I see that you was trying in ksh. Now I can replicate your simptom. The simptom is only when the subprocess is in ksh, I try bash and csh and works OK.

So, for me, ksh must be investigated.

Bojan
Peter Suggitt
Occasional Contributor

Re: Process.destroy kills outer shell when killing inner

Hi

I see what you mean. I have just written a test haness to test this (in isolation) and it would appear that the issue revolves around the linux implementation of KSH.

I have run the same test on solaris and using ksh is OK, if I then try it on Linux it kills the parent processes.

One other thing to note is that when I run on Solaris the parent PID is the java process, when I run in Linux the parent PID is a non-existent process.