sigaction passes SIGINT to system call, but not signal
I have a loop handling an accept(2) call. I want to be able to perform some cleanup when a SIGINT is sent to the program. My first thought was to use the signal function. void signal_handler(int signal) { printf("Caught signal\n"); } int main() { signal(SIGINT, &signal_handler); // ... int accept_fd = accept(sock, NULL, NULL); if (accept_fd == -1) { close(sock); perror("accept"); return 1; } // ... } However, this simply prints "Caught signal" and then the program continues on. If I modify main to use sigaction , the program works as expected. int main() { struct sigaction sa; sa.sa_handler =