Re: A signal fairy tale

From: Dan Kegel (dank@kegel.com)
Date: Fri Jun 29 2001 - 13:46:23 EST


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/



This archive was generated by hypermail 2b29 : Sat Jun 30 2001 - 21:00:22 EST