"I dont quite understand what you mean my trap. Could you please explain?"
A trap command notifies the kernel that you have a section of code to handle certain signals. The trap command give the type of signal(s) that you want to handle and the code to handle that signal(s). After issuing the trap command your code continues normally. If and when the signal occurs the kernel executes the code specified by the trap command and then continues with the main code wherever it happened to be when the signal occured. If the trap code ends with an exit command then the program terminates regardless of what it was doing when the signal occured.
If you issue man trap you will find the explanation for the script command trap buried deep in the explanation of bash. Here is an explanation of how to use trap to exit when a user types ctrl-C.
http://www.freeos.com/guides/lsst/ch04sec12.html
Several languages support signals and trap functions. I have googled for Java trap and can find nothing meaningful. I also googled for Java signals and did find something meaningful. Here is the first explanation I found of Java signal processing.
http://www.geeksville.com/~kevinh/projects/javasignals/
Here is a list of Linux signals.
http://www.comptechdoc.org/os/linux/...pgsignals.html
You are probably interested in signal 17, SIGCHLD. Linux sends SIGCHLD when a child process terminates.
-----------------------------
Steve Stites