Skip Navigation Links | |
Exit Print View | |
man pages section 3: Basic Library Functions Oracle Solaris 11.1 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- retrieve event information from a port
#include <port.h> int port_get(int port, port_event_t *pe, const timespec_t *timeout);
int port_getn(int port, port_event_t list[], uint_t max, uint_t *nget, const timespec_t *timeout);
The port_get() and port_getn() functions retrieve events from a port. The port_get() function retrieves at most a single event. The port_getn() function can retrieve multiple events.
The pe argument points to an uninitialized port_event_t structure that is filled in by the system when the port_get() function returns successfully.
The port_event_t structure contains the following members:
int portev_events; /* detected events */ ushort_t portev_source; /* event source */ uintptr_t portev_object; /* specific to event source */ void *portev_user; /* user defined cookie */
The portev_events and portev_object members are specific to the event source. The portev_events denotes the delivered events. The portev_object refers to the associated object (see port_create(3C)). The portev_source member specifies the source of the event. The portev_user member is a user-specified value.
If the timeout pointer is NULL, the port_get() function blocks until an event is available. To poll for an event without waiting, timeout should point to a zeroed timespec. A non-zeroed timespec specifies the desired time to wait for events. The port_get() function returns before the timeout elapses if an event is available, a signal occurs, a port is closed by another thread, or the port is in or enters alert mode. See port_alert(3C) for details on alert mode.
The port_getn() function can retrieve multiple events from a port. The list argument is an array of uninitialized port_event_t structures that is filled in by the system when the port_getn() function returns successfully. The nget argument points to the desired number of events to be retrieved. The max parameter specifies the maximum number of events that can be returned in list[]. If max is 0, the value pointed to by nget is set to the number of events available on the port. The port_getn() function returns immediately but no events are retrieved.
The port_getn() function block until the desired number of events are available, the timeout elapses, a signal occurs, a port is closed by another thread, or the port is in or enters alert mode.
On return, the value pointed to by nget is updated to the actual number of events retrieved in list.
Threads calling the port_get() function might starve threads waiting in the port_getn() function for more than one event. Similarly, threads calling the port_getn() function for n events might starve threads waiting in the port_getn() function for more than n events.
The port_get() and the port_getn() functions ignore non-shareable events (see port_create(3C)) generated by other processes.
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.
The port_get() and port_getn() functions will fail if:
The port identifier is not valid.
The port argument is not an event port file descriptor.
Event or event list can not be delivered (list[] pointer and/or user space reserved to accomodate the list of events is not reasonable), or the timeout argument is not reasonable.
A signal was caught during the execution of the function.
The timeout element tv_sec is < 0 or the timeout element tv_nsec is < 0 or > 1000000000.
The time interval expired before the expected number of events have been posted to the port.
The port_getn() function will fail if:
The list[] argument is NULL, the nget argument is NULL, or the content of nget is > max and max is > 0.
The timeout argument is not reasonable.
The time interval expired before any events were posted to the port.
Example 1 Send a user event (PORT_SOURCE_USER) to a port and retrieve it with port_get().
The following example sends a user event (PORT_SOURCE_USER) to a port and retrieves it with port_get(). The portev_user and portev_events members of the port_event_t structure are the same as the corresponding user and events arguments of the port_send(3C) function.
#include <port.h> int myport; port_event_t pe; struct timespec timeout; int ret; void *user; uintptr_t object; myport = port_create(); if (myport < 0) { /* port creation failed ... */ ... return(...); } ... events = 0x01; /* own event definition(s) */ object = <myobject>; user = <my_own_value>; ret = port_send(myport, events, user); if (ret == -1) { /* error detected ... */ ... close(myport); return (...); } /* * The following code could also be executed in another thread or * process. */ timeout.tv_sec = 1; /* user defined */ timeout.tv_nsec = 0; ret = port_get(myport, &pe, &timeout); if (ret == -1) { /* * error detected : * - EINTR or ETIME : log error code and try again ... * - Other kind of errors : may have to close the port ... */ return(...); } /* * After port_get() returns successfully, the port_event_t * structure will be filled with: * pe.portev_source = PORT_SOURCE_USER * pe.portev_events = 0x01 * pe.portev_object = <myobject> * pe.portev_user = <my_own_value> */ ... close(myport);
See attributes(5) for descriptions of the following attributes:
|
port_alert(3C), port_associate(3C), port_create(3C), port_send(3C), attributes(5)