/* $OpenBSD: cancel2.c,v 1.2 2003/07/31 21:48:04 deraadt Exp $ */ /* PUBLIC DOMAIN */ /* * Check that a thread waiting on a select without timeout can be * cancelled. */ #include #include #include #include #include "test.h" static void * select_thread(void *arg) { int read_fd = *(int*) arg; fd_set read_fds; int result; FD_ZERO(&read_fds); FD_SET(read_fd, &read_fds); result = select(read_fd + 1, &read_fds, NULL, NULL, NULL); printf("select returned %d\n", result); return 0; } int main(int argc, char *argv[]) { pthread_t thread; int pipe_fd[2]; CHECKe(pipe(pipe_fd)); CHECKr(pthread_create(&thread, NULL, select_thread, pipe_fd)); sleep(2); CHECKr(pthread_cancel(thread)); CHECKr(pthread_join(thread, NULL)); SUCCEED; }