From 8aded40c9003e5c14d436c73f991f4821f8111ff Mon Sep 17 00:00:00 2001 From: Nayan <33187059+GShadow5@users.noreply.github.com> Date: Fri, 9 May 2025 12:32:21 -0400 Subject: [PATCH] add detached state to thread creation --- webserver.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webserver.c b/webserver.c index 53c7e52..61a87ee 100644 --- a/webserver.c +++ b/webserver.c @@ -92,9 +92,15 @@ int main() { continue; } + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_t thread; - pthread_create(&thread, NULL, client_handler, (void *)client); + pthread_create(&thread, &attr, client_handler, (void *)client); pthread_detach(thread); + + pthread_attr_destroy(&attr); } } }