Sun Microsystems, Inc.
spacerspacer
spacer   www.sun.com docs.sun.com | | |  
spacer
black dot
   
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z
    
 
System Calls_lwp_wait(2)


NAME

 _lwp_wait - wait for an LWP to terminate

SYNOPSIS

 
#include <sys/lwp.h>
int _lwp_wait(lwpid_t wait_for, lwpid_t *departed_lwp);

DESCRIPTION

 

The _lwp_wait() function blocks the current LWP until the LWP specified by wait_for terminates. If the specified LWP terminated prior to the call to _lwp_wait(), _lwp_wait() returns immediately. If wait_for is zero, _lwp_wait() waits for any undetached LWP in the current process. If wait_for is not zero, it must specify an undetached LWP in the current process. If departed_lwp is not NULL, it points to a location where the ID of the exited LWP is stored (see _lwp_exit(2)).

When an LWP exits and there are one or more LWPs in the process waiting for this specific LWP to exit, one of the waiting LWPs is unblocked and it returns from _lwp_wait() successfully. Any other LWPs waiting for this same LWP to exit are also unblocked, but they return from _lwp_wait() with an error (ESRCH) indicating the waited-for LWP no longer exists. If there are no LWPs in the process waiting for this specific LWP to exit but there are one or more LWPs waiting for any LWP to exit, one of the waiting LWPs is unblocked and it returns from _lwp_wait() successfully.

If an LWP is waiting for any LWP to exit, it blocks until an undetached LWP for which no other LWP is waiting terminates, at which time it returns successfully, or until all other LWPs in the process are either daemon LWPs or LWPs waiting in _lwp_wait(), in which case it returns EDEADLK.

The ID of an LWP that has exited may be reused via _lwp_create() after the LWP has been successfully waited for.

RETURN VALUES

 

Upon successful completion, 0 is returned. A non-zero value indicates an error.

ERRORS

 

If any of the following conditions occur, _lwp_wait() fails and returns the corresponding value:

EDEADLK
A wait deadlock was detected, such as when an LWP attempts to wait for itself, or the calling LWP is waiting for any LWP to exit and only daemon LWPs or waiting LWPs exist in the process.
EINTR
The _lwp_wait() function was interrupted by a signal.
EINVAL
The LWP with the ID specified by wait_for is a detached LWP.
ESRCH
No LWP with the ID specified by wait_for can be found in the current process.

ATTRIBUTES

 

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPEATTRIBUTE VALUE
MT-LevelAsync-Signal-Safe

SEE ALSO

 

_lwp_create(2), _lwp_detach(2), _lwp_exit(2), attributes(5)


SunOS 5.9Go To TopLast Changed 24 Mar 2000

 
      
      
Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.