signal and error handling in main.c