Fixed signal handler to use sigaction instead of signal