STREAMS-UX Programmer's Guide (February 2007)
STREAMS Mechanism and System Calls
STREAMS System Calls
Chapter 2
18
STREAMS System Calls
User applications use system to operate on STREAMS drivers. The following system calls are discussed in
this chapter:
open(2): Creates a stream to the specified device.
close(2): Closes the stream, free the file descriptor, and if it is the last close(2) on this file
descriptor, will dismantle the associated stream.
read(2): Enables user applications to receive messages from a stream.
write(2): Enables user applications to send messages to a stream.
putmsg(2): Enables user applications to send control information into a stream.
putpmsg(2): Sets priority control for messages written to streams.
getmsg(2): Enables user applications to receive control information from the stream.
getpmsg(2): Enables user applications to receive control information from the stream.
ioctl(2): Accesses and controls a stream. ioctl(2) system calls are used to perform functions that
are specific to a particular device.
poll (2): Provides a synchronous mechanism for querying the stream head read queue for specific
events.
select(2): Notifies the user application about specified file descriptors that are ready for reading,
writing, or pending error conditions. If the specified condition is false for all of the specified
file descriptors, select(2) blocks for the specified timeout interval. select(2) blocks until
the specified condition is true for at least one of the specified file descriptors.
pipe(2): Connects to each other. Each stream head acts as the stream end for the other stream head.
Both stream heads can be used for read and write operations.
STREAMS Library Routines
The following library routines are used in conjunction with STREAMS devices and pipes:
fattach (3C)
Attaches a specified STREAMS file descriptor or pipe to an object in the file system. The
object is designated by a path. The fattach (3C) routine uses a file descriptor and a path
name as input. fattach (3C) returns 0 on success and -1 on failure.
fdetach (3C) Detaches a previously attached streams file descriptor or pipe from an object in the file
system designated by a path. fdetach (3C) uses a path name as input. The fdetach (3C)
routine returns 0 on success and -1 on failure.
isastream (3C) Uses a file descriptor as input and checks to see if this descriptor is associated with a
stream. The isastream (3C) routine returns 1 if the descriptor belongs to a streams device or
STREAMS-based pipe. Else isastream (3C) returns 0. It returns -1 on failure.