Hardware Reference
In-Depth Information
The argument and return values are as follows:
thread : The thread ID of the thread to be altered, so that it
will not wait for a join when it completes. Its resources will be
immediately released upon the named thread's termination.
returns : Zero if the call was successful; otherwise, an error
code is returned (not in errno ).
Error
Description
EINVAL
Thread is not a joinable thread.
ESRCH
No thread with the ID thread could be found.
The pthread_detach function simply requires the thread ID value as its argument:
pthread_t tid; // Thread ID
int rc;
rc = pthread_create(&tid,0,my_thread,0);
assert(!rc);
pthread_detach(tid); // No joining with this thread
pthread_self(3)
Sometimes it is convenient in a piece of code to find out what the current thread ID is. The
pthread_self(3) function is the right tool for the job:
pthread_t pthread_self(void);
An example of its use is shown here:
pthread_t tid;
tid = pthread_self();
pthread_kill(3)
The pthread_kill(3) function allows the caller to send a signal to another thread. The
handling of thread signals is beyond the scope of this text. But there is one very useful
application of this function, which you'll examine shortly:
#include <signal.h>
int pthread_kill(pthread_t thread, int sig);
 
 
Search WWH ::




Custom Search