On Wed, Apr 7, 2021 at 7:31 PM Robins Tharakan <thara...@gmail.com> wrote: > Correct. This is easily reproducible on this test-instance, so let me know if > you want me to test a patch.
>From your description it sounds like signals are not arriving at all, rather than some more complicated race. Let's go back to basics... what does the attached program print for you? I see: tmunro@x1:~/junk$ cc test-signalfd.c tmunro@x1:~/junk$ ./a.out blocking SIGURG... creating a signalfd to receive SIGURG... creating an epoll set... adding signalfd to epoll set... polling the epoll set... 0 sending a signal... polling the epoll set... 1
#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <sys/epoll.h> #include <sys/signalfd.h> #include <unistd.h> int main() { sigset_t mask; int sfd; int epfd; int rc; struct epoll_event event; printf("blocking SIGURG...\n"); sigemptyset(&mask); sigaddset(&mask, SIGURG); sigprocmask(SIG_BLOCK, &mask, NULL); printf("creating a signalfd to receive SIGURG...\n"); sfd = signalfd(-1, &mask, SFD_NONBLOCK | SFD_CLOEXEC); if (sfd < 0) { perror("signalfd"); return EXIT_FAILURE; } printf("creating an epoll set...\n"); epfd = epoll_create1(EPOLL_CLOEXEC); if (epfd < 0) { perror("epoll_create1"); return EXIT_FAILURE; } printf("adding signalfd to epoll set...\n"); event.events = EPOLLIN | EPOLLOUT | EPOLLERR | EPOLLHUP; rc = epoll_ctl(epfd, EPOLL_CTL_ADD, sfd, &event); if (rc < 0) { perror("epoll_ctl"); return EXIT_FAILURE; } printf("polling the epoll set... "); rc = epoll_wait(epfd, &event, 1, 0); printf("%d\n", rc); printf("sending a signal...\n"); kill(getpid(), SIGURG); printf("polling the epoll set... "); rc = epoll_wait(epfd, &event, 1, 0); printf("%d\n", rc); return EXIT_SUCCESS; }