]> PatchyGit - patchyircd.git/commitdiff
use SA_RESTART for SIGINT
authorEgor <egor@patchysicp.xyz>
Sat, 21 Oct 2023 11:23:56 +0000 (14:23 +0300)
committerEgor <egor@patchysicp.xyz>
Sat, 21 Oct 2023 11:26:50 +0000 (14:26 +0300)
SA_RESTART specifically doesn't affect polling syscalls (the thing we
want to interrupt), but it prevents stupid things like having to check
for EINTR on recv/send (which we weren't doing anyway)

src/main.c

index 16d96a8..739a6f0 100644 (file)
@@ -18,7 +18,8 @@ static void set_handler()
        struct sigaction sa;
        sa.sa_handler = on_sigint;
        sigemptyset(&sa.sa_mask);
-       sa.sa_flags = SA_RESETHAND; // only run it once
+       /* Note that SA_RESTART doesn't affect select/poll/epoll_wait. */
+       sa.sa_flags = SA_RESETHAND | SA_RESTART;
        if (sigaction(SIGINT, &sa, NULL) == -1)
                perror("sigaction");
        sa.sa_handler = SIG_IGN;