DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

_lwp_wait(2)


_lwp_wait -- wait for termination of a sibling LWP

Synopsis

   #include <sys/types.h>
   #include <sys/lwp.h>
   

int _lwp_wait(lwpid_t wait_for, lwpid_t *departed_lwp);

Parameters


wait_for
LWP ID of the sibling LWP to wait for

departed_lwp
pointer to the LWP ID of the terminated sibling LWP

Description

_lwp_wait waits for termination of a sibling lightweight process (LWP). and, if the value of the pointer departed_lwp is non-NULL, _lwp_wait sets the location pointed to by departed_lwp to the identifier of the terminated sibling LWP.

Only LWPs created without the LWP_DETACHED flag can be _lwp_waited for.

wait_for parameter

wait_for is the LWP ID of a sibling LWP. If wait_for is equal to the identifier of a currently existing sibling LWP, the function waits until that LWP terminates.

If wait_for is equal to (lwpid_t)0, _lwp_wait will return when any sibling LWP exits and this LWP was successful in waiting for it.

If wait_for has already terminated, _lwp_wait returns immediately.

If wait_for has already been _lwp_waited for, or otherwise is not known by the implementation, an error indication is returned.

departed_lwp parameter

If the value of the pointer departed_lwp is non-NULL, the location pointed to by departed_lwp is set to the identifier of the terminated sibling LWP.

At most one LWP can successfully return from an _lwp_wait due to the termination of a given departed_lwp. If more than one LWP is waiting for a specific departed_lwp, one is successful and the others return ESRCH.

Return values

_lwp_wait returns zero on success, and if the value of the pointer departed_lwp is non-NULL sets the location pointed to by departed_lwp to the identifier of the terminated sibling LWP. On failure, _lwp_wait returns an error number, as described below.

Errors

If any of the following conditions is detected, _lwp_wait returns the corresponding value:

EINTR
The _lwp_wait was interrupted by a signal.

If any of the following conditions occur, _lwp_wait returns the appropriate value:


ESRCH
No LWP can be found in the current process with identity wait_for, or there is an LWP with identity wait_for but it was created with the LWP_DETACHED flag set.

EDEADLK
The calling LWP is attempting to _lwp_wait for itself.

EDEADLK
The calling LWP is waiting for any LWP and there is only one LWP in the process.

References

_lwp_exit(2), waitid(2).

Notices

Lightweight processes (LWPs) are internal interfaces and are subject to change. Their use should be avoided.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004