Re: A signal fairy tale

Dan Kegel
2001-06-29T18:44:44Z

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