Signals and Process Group ID
For SIGURG
and SIGIO
, each socket
has a process number and a process group ID. These values are
initialized to zero, but can be redefined at a later time with the
F_SETOWN
fcntl
()
command, as in
the previous example. A positive third argument to
fcntl
sets the socket's process ID. A negative third
argument to fcntl
()
sets the socket's process group
ID. The only allowed recipient of SIGURG
and
SIGIO
signals is the calling process. A similar
fcntl
(), F_GETOWN
, returns the
process number of a socket. For more information, see the
fcntl
(2) man page.
You can also enable reception of SIGURG
and
SIGIO
by using ioctl
()
to assign the
socket to the user's process group. For more information, see the
ioctl
(2) man page.
/* oobdata is the out-of-band data handling routine */ sigset(SIGURG, oobdata); int pid = -getpid(); if (ioctl(client, SIOCSPGRP, (char *) &pid) < 0) { perror("ioctl: SIOCSPGRP"); }