From c345b8eb08e41982cf11aeaf87dadf6a52e2b671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 20 Jun 2006 22:14:54 +0000 Subject: [PATCH] fix error return codes for posix compatibility git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17885 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/pthread/pthread.c | 14 ++++++++++---- src/system/libroot/posix/pthread/pthread_attr.c | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/system/libroot/posix/pthread/pthread.c b/src/system/libroot/posix/pthread/pthread.c index 7ffabf0249..cc499e47e1 100644 --- a/src/system/libroot/posix/pthread/pthread.c +++ b/src/system/libroot/posix/pthread/pthread.c @@ -30,10 +30,10 @@ pthread_create(pthread_t *_thread, const pthread_attr_t *_attr, thread = spawn_thread((thread_entry)start_routine, "pthread func", attr->sched_priority, arg); if (thread < B_OK) - return thread; + return B_WOULD_BLOCK; + // stupid error code (EAGAIN) but demanded by POSIX resume_thread(thread); - *_thread = thread; return B_OK; @@ -56,7 +56,10 @@ pthread_equal(pthread_t t1, pthread_t t2) int pthread_join(pthread_t thread, void **value_ptr) { - return wait_for_thread(thread, (status_t *)value_ptr); + status_t err = wait_for_thread(thread, (status_t *)value_ptr); + if (err == B_BAD_THREAD_ID) + return ESRCH; + return err; } @@ -70,7 +73,10 @@ pthread_exit(void *value_ptr) int pthread_kill(pthread_t thread, int sig) { - return kill(thread, sig); + status_t err = kill(thread, sig); + if (err == B_BAD_THREAD_ID) + return ESRCH; + return err; } diff --git a/src/system/libroot/posix/pthread/pthread_attr.c b/src/system/libroot/posix/pthread/pthread_attr.c index dcd4d22fa5..7a17ca8114 100644 --- a/src/system/libroot/posix/pthread/pthread_attr.c +++ b/src/system/libroot/posix/pthread/pthread_attr.c @@ -50,7 +50,7 @@ pthread_attr_getdetachstate(const pthread_attr_t *_attr, int *state) { pthread_attr *attr; - if (_attr == NULL || (attr = *_attr) == NULL) + if (_attr == NULL || (attr = *_attr) == NULL || state == NULL) return B_BAD_VALUE; *state = attr->detach_state;