tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: updates?
I have attached the new version.
But it seems both Linux and and netbsd will process signal with large signo
number first.
2016-07-23 23:44 GMT-07:00 Christos Zoulas <christos%zoulas.com@localhost>:
> On Jul 23, 8:03pm, charles.cui1984%gmail.com@localhost (Charles Cui) wrote:
> -- Subject: Re: updates?
>
> | Hi Christos,
> |
> | I have attached a program to test the delivery order of signals.
> | It turns out that both Linux and our current implementation use a FIFO
> | policy to deliver signal, (1. only realtime signals and 2. mix of
> realtime
> | signals and standard signals)
> | I do not know how FreeBSD handles it.
> | Let me know if there are any problems.
>
> Ok good start. Let's add more things in the queue (or split it into
> separate tests) to show that:
> - realtime signals are ordered properly
> - you can queue more than one realtime signal
> - don't use sighold/sigrelse. these are obsolete and release
> only one signal at a time. use sigprocmask (plus since you are
> releasing them one at a time, the release order is the order
> you are going to see them delivered.
>
> Then we can turn it into an ATF test.
>
> Thanks,
>
> christos
>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#define CNT 5
void myhandler(int signo, siginfo_t *info, void *context) {
printf ("Inside Handler = %d\n", signo);
}
int main()
{
int pid, i;
long syslimit;
union sigval value;
struct sigaction act;
int signals[CNT] = {SIGINT+2, SIGRTMIN+1, SIGINT, SIGRTMIN + 0, SIGRTMIN+2};
act.sa_flags = SA_SIGINFO;
act.sa_sigaction = myhandler;
sigemptyset(&act.sa_mask);
for (i = 0; i <CNT; i++)
sigaction(signals[i], &act, 0);
value.sival_int = 0;
pid = getpid();
sigset_t mask, orig;
sigemptyset(&mask);
for (i = 0; i<CNT; i++) sigaddset(&mask, signals[i]);
if (sigprocmask(SIG_BLOCK, &mask, &orig) < 0) {
printf("error in sigprocmask when blocking\n");
return -1;
}
for (i=0; i<CNT; i++) {
if (sigqueue(pid, signals[i], value) != 0) {
printf("call to sigqueue did not return success\n");
}
}
if (sigprocmask(SIG_UNBLOCK, &mask, &orig) < 0) {
printf("error in sigprocmask when unblocking\n");
return -1;
}
sleep(3);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index