diff --git a/visor.c b/visor.c index ec577e2..798e5b5 100644 --- a/visor.c +++ b/visor.c @@ -15,7 +15,6 @@ int32_t thread_count; struct threadInfo { - pthread_t id; int32_t index; // unique number from 0 to thread_count-1 bool drawing; // marks if we are currently drawing for a given thread bool complete; // marks if the drawing that it was supposed to @@ -323,7 +322,9 @@ int main(int argc, char **argv) // we set this before the thread starts so it points to a valid // integer, if the thread fails to start, it will simply be // overwritten by the same value in the next run of the loop - if (pthread_create(&threads[count].id, NULL, &writer_thread, &threads[count].index)) { + pthread_t id; + if (pthread_create(&id, NULL, &writer_thread, &threads[count].index)) { + pthread_detach(id); fprintf(stderr, "Failed to create thread %d\n", i); continue; }