Add sigqueue test code.
This commit is contained in:
parent
4a1f4e2a13
commit
60d3d21057
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152155
5
tools/regression/sigqueue/Makefile
Normal file
5
tools/regression/sigqueue/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SUBDIR=sigqtest1
|
||||
|
||||
.include <bsd.subdir.mk>
|
8
tools/regression/sigqueue/sigqtest1/Makefile
Normal file
8
tools/regression/sigqueue/sigqtest1/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG=sigqtest1
|
||||
LDADD+=
|
||||
NO_MAN=
|
||||
DEBUG_FLAGS=-g
|
||||
|
||||
.include <bsd.prog.mk>
|
49
tools/regression/sigqueue/sigqtest1/sigqtest1.c
Normal file
49
tools/regression/sigqueue/sigqtest1/sigqtest1.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* $FreeBSD$ */
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
|
||||
int received;
|
||||
|
||||
void handler(int sig, siginfo_t *si, void *ctx)
|
||||
{
|
||||
if (si->si_code != SI_QUEUE)
|
||||
errx(1, "si_code != SI_QUEUE");
|
||||
if (si->si_value.sival_int != received)
|
||||
errx(1, "signal is out of order");
|
||||
received++;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
struct sigaction sa;
|
||||
union sigval val;
|
||||
int ret;
|
||||
int i;
|
||||
sigset_t set;
|
||||
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_sigaction = handler;
|
||||
sigaction(SIGRTMIN, &sa, NULL);
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGRTMIN);
|
||||
sigprocmask(SIG_BLOCK, &set, NULL);
|
||||
i = 0;
|
||||
for (;;) {
|
||||
val.sival_int = i;
|
||||
ret = sigqueue(getpid(), SIGRTMIN, val);
|
||||
if (ret == -1) {
|
||||
if (errno != EAGAIN) {
|
||||
errx(1, "errno != EAGAIN");
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
sigprocmask(SIG_UNBLOCK, &set, NULL);
|
||||
if (received != i)
|
||||
errx(1, "error, signal lost");
|
||||
printf("OK\n");
|
||||
}
|
Loading…
Reference in New Issue
Block a user