fix error return codes for posix compatibility

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17885 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2006-06-20 22:14:54 +00:00
parent 74ef162141
commit c345b8eb08
2 changed files with 11 additions and 5 deletions
+10 -4
View File
@@ -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); thread = spawn_thread((thread_entry)start_routine, "pthread func", attr->sched_priority, arg);
if (thread < B_OK) if (thread < B_OK)
return thread; return B_WOULD_BLOCK;
// stupid error code (EAGAIN) but demanded by POSIX
resume_thread(thread); resume_thread(thread);
*_thread = thread; *_thread = thread;
return B_OK; return B_OK;
@@ -56,7 +56,10 @@ pthread_equal(pthread_t t1, pthread_t t2)
int int
pthread_join(pthread_t thread, void **value_ptr) 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 int
pthread_kill(pthread_t thread, int sig) 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;
} }
@@ -50,7 +50,7 @@ pthread_attr_getdetachstate(const pthread_attr_t *_attr, int *state)
{ {
pthread_attr *attr; pthread_attr *attr;
if (_attr == NULL || (attr = *_attr) == NULL) if (_attr == NULL || (attr = *_attr) == NULL || state == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
*state = attr->detach_state; *state = attr->detach_state;