summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTazyFoundSoup <gardendistrict0x0@outlook.com>2026-06-11 19:07:07 +1000
committerTazyFoundSoup <gardendistrict0x0@outlook.com>2026-06-11 19:07:07 +1000
commit039452e45658a1160cebe8937133d3fe7f9265b4 (patch)
treeac3b8771a9b7415aae27f942b16dc2453ecf3747 /src
parentedc34e77d5f19aa2a697f16d9e2d24677dafb506 (diff)
feat(thread): Check pthread_create result and detach thread in bridge
Diffstat (limited to 'src')
-rw-r--r--src/bridges/pthread/thread_bridge.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bridges/pthread/thread_bridge.c b/src/bridges/pthread/thread_bridge.c
index e014a3a..1cafacd 100644
--- a/src/bridges/pthread/thread_bridge.c
+++ b/src/bridges/pthread/thread_bridge.c
@@ -1,10 +1,20 @@
#ifdef USE_THREAD
#include <bridges/pthread/thread_bridge.h>
+#include <pthread.h>
+#include <errno.h>
pthread_t run_job_in_thread(ff_thread_job *job) {
pthread_t thread;
- pthread_create(&thread, NULL, ff_thread_wrapper, job);
+ int r = pthread_create(&thread, NULL, ff_thread_wrapper, job);
+ if (r != 0) {
+ // pthread_create failed; return an invalid thread value (0) to signal error
+ return (pthread_t)0;
+ }
+
+ // Detach the thread to avoid requiring callers to join it. If you want join
+ // semantics, consider changing the API to return an error and an out pthread_t.
+ pthread_detach(thread);
return thread;
}