Block until a thread terminates
#include <sys/neutrino.h> int ThreadJoin( int tid, void** status ); int ThreadJoin_r( int tid, void** status );
- The ID of the thread that you want to detach, as returned by ThreadCreate().
- The address of a pointer to a location where the function can store the thread's exit status.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The ThreadJoin() and ThreadJoin_r() kernel calls block until the thread specified by tid terminates. If status isn't NULL, the functions save the thread's exit status in the area pointed to by status. If the thread tid has already terminated, the functions immediately return with success and the status, if requested.
These functions are identical except in the way they indicate errors. See the Returns section for details.
When ThreadJoin() returns successfully, the target thread has been successfully terminated. Until this occurs, the thread ID tid isn't reused and a small kernel resource (a thread object) is retained.
- The calling thread blocks waiting for the indicated thread to exit.
The only difference between these functions is the way they indicate errors:
- If an error occurs, the function returns -1 and sets errno. Any other value returned indicates success.
- Returns EOK on success. This function does NOT set errno. If an error occurs, the function may return any value listed in the Errors section.
- Attempt to join a thread which has been joined by another thread.
- Attempt to join to yourself.
- A fault occurred when the kernel tried to access status.
- The call was interrupted by a signal.
- Attempt to join a thread which is detached (see ThreadDetach()).
- The thread indicated by tid doesn't exist.
- A kernel timeout unblocked the call. See TimerTimeout().
Last modified: 2013-09-30