The SIGIO signal notifies a process when a socket (actually any file descriptor) has finished a data transfer. The steps in using SIGIO are:
Set up a SIGIO signal handler with thesignal(3C) or sigvec(3UCB) calls.
Use fcntl(2) to set the process ID or process group ID to route the signal to its own process ID or process group ID (the default process group of a socket is group 0).
Convert the socket to asynchronous, as shown in "Asynchronous Socket I/O".
Example 2-15 shows some sample code to allow a given process to receive information on pending requests as they occur for a socket. With the addition of a handler for SIGURG, this code can also be used to prepare for receipt of SIGURG signals.
#include <fcntl.h> #include <sys/file.h> ... signal(SIGIO, io_handler); /* Set the process receiving SIGIO/SIGURG signals to us. */ if (fcntl(s, F_SETOWN, getpid()) < 0) { perror("fcntl F_SETOWN"); exit(1); }