bart | 3f5cc7e | 2011-03-09 17:50:34 +0000 | [diff] [blame] | 1 | /* Invoke pthread_detach() with an invalid thread ID. */ |
| 2 | |
| 3 | #include <assert.h> |
| 4 | #include <errno.h> |
| 5 | #include <pthread.h> |
| 6 | #include <stdio.h> |
| 7 | |
| 8 | static void* thread_func(void* arg) |
| 9 | { |
| 10 | return 0; |
| 11 | } |
| 12 | |
| 13 | int main(int argc, char** argv) |
| 14 | { |
| 15 | pthread_t thread; |
| 16 | |
| 17 | pthread_create(&thread, NULL, thread_func, NULL); |
| 18 | pthread_join(thread, NULL); |
| 19 | |
| 20 | /* Invoke pthread_detach() with the thread ID of a joined thread. */ |
| 21 | pthread_detach(thread); |
| 22 | |
| 23 | /* Invoke pthread_detach() with an invalid thread ID. */ |
petarj | c9fa640 | 2012-12-20 19:02:17 +0000 | [diff] [blame] | 24 | pthread_detach(thread + 8); |
bart | 3f5cc7e | 2011-03-09 17:50:34 +0000 | [diff] [blame] | 25 | |
| 26 | fprintf(stderr, "Finished.\n"); |
| 27 | |
| 28 | return 0; |
| 29 | } |