added signal handler for SIGSEGV and SIGTERM