It's probably something in the OS doing it, not within your script. If you're running Linux with a 2.4 or higher kernel, it will often be configured to kill off processes automatically if they reach a certain level of CPU or memory usage. Another possibility is ulimit (altho I'm not sure if that kills processes or just limits them).