Add test case for sigpending().

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@452
This commit is contained in:
Julian Seward 2002-06-20 08:17:07 +00:00
parent c489fb0318
commit 314f516b09
2 changed files with 56 additions and 1 deletions

View File

@ -31,4 +31,4 @@ EXTRA_DIST = \
discard.c pth_semaphore1.c new_override.cpp pth_yield.c \
sigaltstack.c erringfds.c sigwait_all.c \
pth_cancel1.c pth_cancel2.c pth_signal_gober.c nanoleak.c \
pth_pause.c
pth_pause.c pth_sigpending.c

55
tests/pth_sigpending.c Normal file
View File

@ -0,0 +1,55 @@
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <errno.h>
#include <assert.h>
int show ( void )
{
int res, i, ret;
sigset_t pend;
res = sigpending(&pend);
printf("pending signals:\n");
assert(res == 0);
ret = 0;
for (i = 1; i < 64; i++) {
if (sigismember(&pend,i)) {
printf(" sig %d now pending\n", i);
ret = 1;
}
}
return ret;
}
void hdlr ( int sig )
{
printf("signal %d arrived (unexpectedly!)\n", sig);
}
int main ( void )
{
int res;
sigset_t set;
/* Force use of libpthread here */
pthread_testcancel();
printf("installing handler\n");
signal(SIGINT, hdlr);
/* and block it ... */
sigemptyset(&set);
sigaddset(&set, SIGINT);
res = pthread_sigmask(SIG_BLOCK, &set, NULL);
assert(res == 0);
printf("installing handler done; please do Control-C\n");
while (1) {
res = show();
if (res) break;
sleep(1);
}
printf("control-C now pending -- bye\n");
return 0;
}