Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
spt_writez(2) OSS System Calls Reference Manual
The spt_fcntlz( ) function provides more information about record locks.
If it is interrupted by a signal before it writes any data, the spt_writez() function returns the
value -1 with errno set to [EINTR]. If it is interrupted by a signal after it has successfully written
some data, the spt_writez() function returns the number of bytes that it has written.
Use on Guardian Objects
Attempting to write to a Guardian file (that is, a file in /G) that is locked causes the spt_writez()
function to return -1 and set errno to [EGUARDIANLOCKED].
NOTES
For file descriptors for non-regular files, the spt_writez() function behaves exactly the same as
spt_writex(). 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_writez() 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.
For C applications, a macro to map write( ) to spt_writez() is available when you use the
#define SPT_THREAD_AWARE_XNONBLOCK preprocessor directive before including
spthread.h or when you use an equivalent compiler command option to compile the application.
For C++ applications, an alias to map write( ) to spt_writez() is available when you use the
#define SPT_THREAD_AWARE_PRAGMA_XNONBLOCK preprocessor directive before
including spthread.h or when you use an equivalent compiler command option to compile the
application.
To use this function in a threaded application that uses the Standard POSIX Threads library on
systems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the fol-
lowing tasks:
• Include the spthread.h header file in the application.
• Compile the application using the _SPT_MODEL_ feature test macro or equivalent
compiler command option in addition to any other feature test macros in use.
• Link the application to the zsptdll library (/G/system/zdllnnn/zsptdll).
RETURN VALUES
Upon successful completion, the spt_writez() function returns the number of bytes that were
actually written. Otherwise, the value -1 is returned, and errno is set to indicate the error.
ERRORS
If any of these conditions occurs, the spt_writez() function sets errno to the corresponding
value:
[EAGAIN] One of these conditions exists:
• An attempt was made to write to a file descriptor that cannot accept data,
and the O_NONBLOCK flag is set.
• A write to a pipe (FIFO file) of PIPE_BUF bytes or less is requested,
O_NONBLOCK is set, and fewer than nbytes of free space are avail-
able.
• The O_NONBLOCK flag is set on this file, and the process would be
delayed in the write operation.
7−490 Hewlett-Packard Company 527186-023