Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

read(2) OSS System Calls Reference Manual
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.
Use From a Threaded Application
The thread-aware read() function behaves exactly the same as spt_readz() in the Standard
POSIX Threads library. For file descriptors for regular files, if this thread-aware read() function
must wait for an I/O operation to complete on an open file, this function blocks the thread
(instead of the entire process) that called it, while it waits for the I/O operation to complete.
This function serializes file operations on an open file. If a thread calls read() 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.
NOTES
To use the read() functionality in a threaded application that uses the Standard POSIX Threads
library, see spt_readz(2).
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the fol-
lowing tasks to make the function thread-aware in a multi-threaded application:
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
Link the application to the zputdll library (/G/system/zdllnnn/zputdll).
On systems running H06.24 or later H-series RVUs or J06.13 or later J-series RVUs, you can use
this function with 32-bit or 64-bit OSS applications.
To use this function in a 32-bit threaded application that uses the POSIX User Thread Model
library on systems running H06.24 or later RVUs or J06.13 or later RVUs, perform the same
tasks (described above) used to enable the function on systems running H06.21/J06.10 or later
RVUs.
To use this function in a 64-bit threaded application that uses the POSIX User Thread Model
library on systems running H06.24 or later RVUs or J06.13 or later RVUs, you must perform all
of the following tasks:
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
Compile the application using the -Wlp64 compiler command option.
Link the application to the yputdll library (/G/system/zdllnnn/yputdll).
For detailed information about writing multi-threaded and 64-bit applications for the Open Sys-
tem Services environment, see the Open System Services Programmer’s Guide.
RETURN VALUES
Upon successful completion, the read() function returns the number of bytes actually read and
placed into the buffer. The function guarantees to read the number of bytes requested only if the
descriptor references a regular file that has at least that number of bytes left before EOF.
If the read otherwise fails, the value -1 is returned, errno is set to indicate the error, and the con-
tents of the buffer pointed to by the buffer parameter are indeterminate.
64 Hewlett-Packard Company 527186-023