[1627] in linux-net channel archive
Sockets und Signals
daemon@ATHENA.MIT.EDU (NIIBE Yutaka)
Mon Jan 15 00:35:55 1996
Date: Mon, 15 Jan 1996 13:14:28 +0900
From: NIIBE Yutaka <gniibe@mri.co.jp>
To: schorn@str.daimler-benz.com, aschorn@ba-stuttgart.de (Alexander Schorn)
Cc: linux-net@vger.rutgers.edu
In-Reply-To: <4d58o0$38s@news.belwue.de>
Alexander Schorn writes:
> To make this class completely
> signaldriven (without useing polling) I have to tell the kernel to
> generate the appropriate signal when data arrives. Under SunOS
> and HPUX this is done by
> ioctl(descriptor, I_SETSIG, signal);
> where signal could be S_INPUT | S_RDNORM for example.
This works if the socket is implemented on STREAM. For Linux and
4.3+BSD, you can use:
fcntl (descriptor, F_SETFL, FASYNC);
Then, it will generate SIGIO.
In our sources, there is code like following:
===========
#ifdef FASYNC
if (fcntl(sock, F_SETFL, FASYNC|O_NONBLOCK) < -1) {
fatalp(\"fcntl\", \"Setting error for %%s\", msg);
}
#else
if (fcntl(sock, F_SETFL, O_NONBLOCK) < -1) {
fatalp(\"fcntl\", \"Setting error for %%s\", msg);
}
if (ioctl(sock, I_SETSIG, S_INPUT|S_OUTPUT) != 0) {
fatalp(\"ioctl\", \"Setting error for %%s\", msg);
}
#endif
===========
> Where to find information about this theme ?
"12.6 Asynchronous I/O" in the book "Advanced Programming in the UNIX
Environment" by W. Richard Stevens (Addison-Wesley).
However, I don't recommend use of SIGIO, since it is kludge. For
example, SIGIO may not be generated for OUTPUT on SunOS 4.1.3, the
system may hang on OSF/1 on the condition of OUTPUT SIGIO.
We've desided that getting rid of the code above, and using polling
based approach with select(2) because it is portable and stable.
In the future, we use 'aio_' of POSIX.4. See "Asynchronous I/O" in
the book "POSIX.4: Programming for the Real World" by Bill
O. Gallmeister (O'Reilly & Associates, Inc.).
Thanks,
--
NIIBE Yutaka
Mitsubishi Research Institute, Inc.