tjoin

Number0x0A
Signature(tid) -> exit_status or -err
Grouptask
Since1.0
Blockingtrue

Block until a thread in the same process exits, returning its exit status. If the thread has already exited, returns its status immediately without blocking.

Only threads within the caller’s own process can be joined since a tid is an identifier inside a process, not a cross-process handle.

Pitfalls

The exit status is returned directly in r0, in the same register the error codes use. A thread that exits with a small negative status (e.g. tquit(-2)) is indistinguishable from an error like ERR_NOENT. Reserve non-negative exit codes, or carry status out-of-band.

Arguments

RegisterNameDescription
r0tidThread ID to join, within the calling process

Returns

The joined thread's exit status.

Errors

CodeCondition
ERR_NOENTNo thread with that tid exists
ERR_NOPERMThe thread belongs to another process

See also