Re: A signal fairy tale

Dan Kegel (dank@kegel.com)
Fri, 29 Jun 2001 11:46:23 -0700


Dan Kegel wrote:
> Pseudocode:
>
> sigemptyset(&s);
> sigaddset(SIGUSR1, &s);
> fd=sigopen(&s);
> m=read(fd, buf, n*sizeof(siginfo_t))
> close(fd);
>
> should probably be equivalent to
>
> sigemptyset(&s);
> sigaddset(SIGUSR1, &s);
> struct sigaction newaction, oldaction;
> newaction.sa_handler = dummy_handler;
> newaction.sa_flags = SA_SIGINFO;
> newaction.sa_mask = 0;
> sigaction(SIGUSR1, &newaction, &oldaction);

I forgot to mask off the signal to avoid traditional delivery:

sigprocmask(SIG_BLOCK, &s, &oldmask);

> for (i=0; i<n; i++)
> if (sigwaitinfo(&s, buf+i))
> break;
> m = n * sizeof(siginfo_t);
> sigaction(SIGUSR1, &oldaction, 0);

sigprocmask(SIG_UNBLOCK, &s);

> (apologies if any of the above is wrong)

- Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/