Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) spt_readz(2)
When attempting to read from an empty pipe (or FIFO file):
• If no process has the pipe open for writing, the spt_readz() function returns the value 0
(zero) to indicate EOF.
• If some process has the pipe open for writing:
— If the O_NONBLOCK flag is not set, the spt_readz() function blocks until
either some data is written or the pipe is closed by all processes that had opened
the pipe for writing.
— If the O_NONBLOCK flag is set, the spt_readz() function returns the value -1
and sets errno to [EAGAIN].
When attempting to read from a socket and no data is currently available:
• If the O_NONBLOCK flag is not set, the spt_readz() function blocks until data
becomes available or an error occurs.
• If the O_NONBLOCK flag is set, the spt_readz() function returns the value -1 and sets
errno to [EWOULDBLOCK].
When attempting to read from a character special file that supports nonblocking reads, such as a
terminal, and no data is currently available:
• If the O_NONBLOCK flag is not set, the spt_readz() function blocks until data
becomes available or an error occurs.
• If the O_NONBLOCK flag is set, the spt_readz() function returns the value -1 and sets
errno to [EAGAIN].
If it is interrupted by a signal before it reads any data, the spt_readz() function returns the value
-1 with errno set to [EINTR]. If it is interrupted by a signal after it has successfully read some
data, the spt_readz() function returns the number of bytes read.
The spt_readz() function returns the number of bytes with the value 0 (zero) for any unwritten
portion of a regular file prior to EOF.
When reading from a device special file, the return of EOF has no effect on subsequent calls to
the spt_readz() function. When modem disconnect is detected, an EOF is returned. The errno
variable is not set to [EIO].
Upon successful completion, the spt_readz() function marks the st_atime field of the file for
update.
Use on Guardian Objects
After a call to the fork(), tdm_fork(),ortdm_spawn() function, the initial position within a
Guardian EDIT file (a file in /G with file code 101) is the same for both parent and child
processes. However, the position is not shared. Moving the current position from within one
process does not move it in the other process.
NOTES
For file descriptors for special files, the spt_readz() function behaves exactly the same as
spt_readx(). For file descriptors for regular files, this is a thread-aware function: if this function
must wait for an I/O operation to complete on an open file, this function blocks the thread that
called it (instead of the entire process), while it waits for the I/O operation to complete.
This function serializes file operations on an open file. If a thread calls spt_readz() to access a
file that already has a file operation in progress by a different thread, this thread is blocked until
the prior file operation is complete.
527186-023 Hewlett-Packard Company 7−359