inet_pton tests, fix regression test case
[libc-test.git] / src / regression / pthread_exit-cancel.c
blob7a8d00ba92db54fe154a31bf9eaac15ccdc76b75
1 // commit: 1a9a2ff7b0daf99100db53440a0b18b2801566ca 2011-02-13
2 // pthread_exit should call cancelation handlers
3 #include <pthread.h>
4 #include <string.h>
5 #include "test.h"
7 #define TEST(r, f) if (((r)=(f))) t_error(#f " failed: %s\n", strerror(r))
9 static void cleanup(void *arg)
11 *(int *)arg = 1;
14 static void *start(void *arg)
16 pthread_cleanup_push(cleanup, arg);
17 pthread_exit(0);
18 pthread_cleanup_pop(0);
19 return arg;
22 int main(void)
24 pthread_t td;
25 void *status;
26 int arg = 0;
27 int r;
29 TEST(r, pthread_create(&td, 0, start, &arg));
30 TEST(r, pthread_join(td, &status));
31 if (status)
32 t_error("expected 0 thread exit status, got 0x%lx\n", (long)status);
33 if (arg != 1)
34 t_error("cleanup handler failed to run\n");
35 return t_status;