On 2024-05-22 02:46, Xiao Ni wrote: > Hi Logan > > Thanks for your suggestion. I tried to create signalfd before fork() > but it still can't work. And I call sleep(2) before child exits, the > problem still can happen sometimes. This is what I tried. If you have > time to have a look, it's great. It's not a hurry thing. Can you send sample prints from this patch? I'm very surprised that with the delay on the child processes it can still happen. What do you do to make it happen? How frequently does it occur? > @@ -185,17 +186,6 @@ static int wait_for_zero_forks(int *zero_pids, int count) > if (!wait_count) > return 0; > > - sigemptyset(&sigset); > - sigaddset(&sigset, SIGINT); > - sigaddset(&sigset, SIGCHLD); > - sigprocmask(SIG_BLOCK, &sigset, NULL); > - > - sfd = signalfd(-1, &sigset, 0); > - if (sfd < 0) { > - pr_err("Unable to create signalfd: %s\n", strerror(errno)); > - return 1; > - } Strictly speaking, I don't think it's necessary to move the signalfd initialization. Blocking the signals should be enough, then any signals can be retrieved at a later time with signalfd. Though, I don't think it should hurt to do it this way. Logan