Add a test that a cancellation registered while cancellation is enabled
is not honored while cancellation is disabled.
This commit is contained in:
parent
808b43aeb1
commit
dfd29b093b
|
@ -0,0 +1,15 @@
|
|||
# $NetBSD: Makefile,v 1.1 2003/07/22 21:26:13 nathanw Exp $
|
||||
|
||||
WARNS=1
|
||||
|
||||
PROG= cancel2
|
||||
SRCS= cancel2.c
|
||||
|
||||
LDADD= -lpthread
|
||||
|
||||
NOMAN=
|
||||
|
||||
regress:
|
||||
./cancel2
|
||||
|
||||
.include <bsd.prog.mk>
|
|
@ -0,0 +1,25 @@
|
|||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
char str1[] = "You should see this.\n";
|
||||
char str2[] = "You shoukd not see this.\n";
|
||||
|
||||
printf("Cancellation test 2: Self-cancellation and disabling.\n");
|
||||
|
||||
|
||||
pthread_cancel(pthread_self());
|
||||
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
||||
|
||||
write(STDOUT_FILENO, str1, sizeof(str1));
|
||||
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||
|
||||
write(STDOUT_FILENO, str2, sizeof(str2));
|
||||
|
||||
exit(1);
|
||||
}
|
Loading…
Reference in New Issue