add detached state to thread creation

This commit is contained in:
Nayan
2025-05-09 12:32:21 -04:00
parent 4445224525
commit 8aded40c90

View File

@@ -92,9 +92,15 @@ int main() {
continue; continue;
} }
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, client_handler, (void *)client); pthread_create(&thread, &attr, client_handler, (void *)client);
pthread_detach(thread); pthread_detach(thread);
pthread_attr_destroy(&attr);
} }
} }
} }