--- In nslu2-linux@yahoogroups.com, "clerew5" <clerew5@...> wrote:
>
> The following program works fine on my SPARC solaris system:
Replying to my own question, it seems that sigwait expects the signal to be 'blocked' before you attempt to wait upon it. The additional code below shows what is needed to make it work. It is still unclear why Solaris worked without it (probably the order in which various things are tested within the kernel).
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <ctype.h>
> #include <sys/types.h>
> #include <unistd.h>
> #include <signal.h>
>
> sigset_t blockset;
>
> int count = 0;
>
> void
> take_action(int signal)
> {
> printf("%d\n", count++);
> }
>
> main()
> {
> int signal;
> sigemptyset(&blockset);
> sigaddset(&blockset, SIGUSR1);
sigprocmask(SIG_BLOCK, &blockset, NULL);
/* should probably have used pthread_sigmask */
>
> while(1) {
> sigwait(&blockset, &signal);
> take_action(signal);
> }
> }
>
> It sits in a loop waiting for a SIGUSR1 signal, and when it comes it prints out that it has seen it. The intention is that if several such signals are received in rapid succession, the first will be actioned and the rest will be queued up and processed on subsequent cycles of the loop.
Friday, October 22, 2010
[nslu2-linux] Re: Sigwait
__._,_.___
MARKETPLACE
.
__,_._,___
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment