diff options
author | rpj <rpj> | 2003-08-14 08:53:17 +0000 |
---|---|---|
committer | rpj <rpj> | 2003-08-14 08:53:17 +0000 |
commit | a50745ec922a917513029f3f87bf820827b43f29 (patch) | |
tree | 1e221862e0550d163baef12d17634430ae677824 /pthread_detach.c | |
parent | 414f4bd7e70d94025576d9264c86da63c506f6ca (diff) |
Reuse of thread IDs, improved thread ID validation, new tests, bug fixes.
Diffstat (limited to 'pthread_detach.c')
-rw-r--r-- | pthread_detach.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/pthread_detach.c b/pthread_detach.c index 423997d..a54a7e8 100644 --- a/pthread_detach.c +++ b/pthread_detach.c @@ -38,9 +38,15 @@ #include "pthread.h" #include "implement.h" +/* + * Not needed yet, but defining it should indicate clashes with build target + * environment that should be fixed. + */ +#include <signal.h> + int -pthread_detach (pthread_t tid) +pthread_detach (pthread_t thread) /* * ------------------------------------------------------ * DOCPUBLIC @@ -70,17 +76,21 @@ pthread_detach (pthread_t tid) { int result; - if (tid == NULL || - tid->detachState == PTHREAD_CREATE_DETACHED) + /* This is the proper way to test for a valid thread. */ + result = pthread_kill(thread, 0); + if (0 != result) { + return result; + } + if (thread->detachState == PTHREAD_CREATE_DETACHED) + { result = EINVAL; - } else { result = 0; - tid->detachState = PTHREAD_CREATE_DETACHED; + thread->detachState = PTHREAD_CREATE_DETACHED; } return (result); |