DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
STREAMS polling and multiplexing

STREAMS input/output polling

This section describes the synchronous polling mechanism and asynchronous event notification within STREAMS.

User processes can efficiently monitor and control multiple Streams with two system calls: poll and the I_SETSIG ioctl command. These calls allow a user process to detect events that occur at the Stream head on one or more Streams, including receipt of data or messages on the read queue and cessation of flow control.

To monitor Streams with poll, a user process issues that system call and specifies the Streams to be monitored, the events to look for, and the amount of time to wait for an event. The poll system call blocks the process until the time expires or until an event occurs. If an event occurs, it returns the type of event and the Stream on which the event occurred.

Instead of waiting for an event to occur, a user process may want to monitor one or more Streams while processing other data. It can do so by issuing the I_SETSIG ioctl command, specifying one or more Streams and events (as with poll). This ioctl does not block the process and force the user process to wait for the event but returns immediately and issues a signal when an event occurs. The process must specify a signal handler to catch the resultant ``SIGPOLL'' signal.

If any selected event occurs on any of the selected Streams, STREAMS causes the ``SIGPOLL'' catching function to be executed in all associated requesting processes. However, the process(es) will not know which event occurred, nor on what Stream the event occurred. A process that issues the I_SETSIG can get more detailed information by issuing a poll after it detects the event.


Next topic: Synchronous input/output
Previous topic: STREAMS polling and multiplexing

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004