Open System Services Programmer's Guide

my_printf("Signal received is %d\n",signo);
}
Thread-Aware and Nonblocking OSS Functions
If a function must wait for an I/O operation to complete, the function blocks its caller (either a
thread or a process) from continuing until the I/O operation completes. A function that blocks all
threads while it waits for I/O to complete is a process-blocking function. Process-blocking functions
are not thread aware. If a thread calls a process-blocking function, the calling thread and all the
other threads in the process are prevented from continuing until the I/O operation is complete and
the function returns a status indication. Standard OSS I/O library functions are not thread-aware.
In contrast to a process-blocking function, a thread-aware function blocks only the thread calling
that function, instead of blocking all threads in the process. The other threads in the process can
continue doing work while the calling thread waits for I/O to complete. A thread-aware function
is sometimes called a thread-blocking function, because it blocks only the calling thread.
Sometimes it is not enough for a function to be thread-aware. There can be times when you do not
want even the calling thread to wait for I/O to complete. Instead, you want the function to either
succeed immediately or to fail immediately. Functions that do not block the calling thread or the
other threads in the process are nonblocking functions. Nonblocking I/O functions are sometimes
called asynchronous I/O functions.
The behavior of an OSS I/O library function can vary according to these factors:
Whether the file descriptor is for a regular file or a non-regular file.
Whether the function was designed to be process-blocking, thread-aware (thread-blocking),
or nonblocking for that type of file.
Whether the file descriptor passed to the function is nonblocking. A file descriptor is
nonblocking when one of these conditions is true:
The file descriptor has the O_NONBLOCK flag set.
The file descriptor has been set to non-blocking mode by setting the argument to the
request parameter to F_SETFL when calling the fcntl() function.
Regular Files
For regular files, thread-aware functions block the calling thread but allow the other threads to run,
whether or not the file descriptor is nonblocking. These functions never return the errors EAGAIN,
EINPROGRESS, or EWOULDBLOCK for regular files, so there are no nonblocking thread-aware
functions for regular files. Table 69 (page 398) lists the functions for which PUT Model library
provides a version that is thread-aware for regular files. You can disable thread-aware I/O for
regular files by setting the PUT_THREAD_AWARE_REGULAR_IO_DISABLE environment variable
before you start the process.
In addition to the functions listed in Table 69 (page 398), these additional functions, although not
thread-aware, support the use of thread-aware functions by serializing file operations on an open
file:
dup2()
fstat64()
fstat()
lseek64()
lseek()
396 Using the POSIX User Thread (PUT) Model Library