USOPENPOLLSEMA(3P)                                          USOPENPOLLSEMA(3P)


NAME
     usopenpollsema - attach a file descriptor to a pollable semaphore

C SYNOPSIS
     #include <ulocks.h>

     int usopenpollsema (usema_t *sema, mode_t acc);

DESCRIPTION
     usopenpollsema attaches a file descriptor to a pollable semaphore.  The
     returned file descriptor is used when calling poll(2) or select(2) to
     acquire the semaphore after an unsuccessful uspsema(3P).

     If the caller is the first process to call usopenpollsema on sema then a
     new semaphore device is allocated (see usema(7M)).  The user and group id
     of the semaphore device take on the effective user/group id of the
     caller.  The access mode is set to acc(see chmod(2)).  Calls to
     usopenpollsema on the same semaphore by other processes simply attach to
     the previously allocated device.  They must pass standard Unix file
     permission tests to be allowed to attach.

     All processes sharing a pollable semaphore, related and unrelated alike,
     must call usopenpollsema before performing any semaphore operation on
     sema.

     Forked children must perform their own usopenpollsema, as the file
     descriptor inherited from the parent through the fork(2) will not be
     usable.

     A process requires the file descriptor to call usvsema even if it never
     calls uspsema.

     usopenpollsema will fail if one or more of the following are true:

     [EACCES]      The caller does not have the required permission to open
                   one or both of the two semaphore device files, /dev/usema
                   and /dev/usemaclone.

     [EACCES]      The caller is attempting to attach to a previously
                   allocated semaphore device and does not have the requisite
                   permissions.

     [ENOSPC]      There are no more selectable semaphores available in the
                   system.  This is configurable up to 255.  See
                   /var/sysgen/master.d/usema.

     [EMFILE]      The system imposed limit for open file descriptors per
                   process {OPEN_MAX} has already been reached.

     [ENFILE]      The system file table has exceeded {NFILE_MAX} concurrently
                   open files.


     [ENXIO]       One or both of the two semaphore device files, /dev/usema
                   and /dev/usemaclone, do not exist, or the device is not
                   configured into the system.

SEE ALSO
     chmod(2), open(2), amalloc(3P), usclosepollsema(3P), usconfig(3P),
     uscpsema(3P), usctlsema(3P), usdumpsema(3P), usfreesema(3P),
     usfreepollsema(3P), usinit(3P), usnewsema(3P), usnewpollsema(3P),
     uspsema(3P), usvsema(3P), usema(7M).

DIAGNOSTICS
     Upon successful completion, a file descriptor is returned. Otherwise, a
     value of -1 is returned and errno is set to indicate the error.


                                                                        Page 2