[UCLA-LUG] Async I/O notification on FIFOs possible??
Kai-Min Sung
linux@linux.ucla.edu
Thu Aug 16 15:22:01 2001
I can't seem to get asynchronous I/O notification on a FIFO working on
Linux. I've heard some rumors that it isn't implemented yet in Linux, but
it seems like such a trivial thing to do. Can someone confirm that
it does/doesn't work?
Here's the code I used to test. No matter what I try writing to the FIFO,
there is no SIGIO being generated.
-Kai
kaimin@cs.ucla.edu
--- code snippit ---
void sigio(int signal)
{
printf("received signal %d\n", signal);
fflush(NULL);
}
int main()
{
int fd;
/* Register SIGIO handler */
signal(SIGIO, sigio);
/* Create the FIFO */
mkfifo("/tmp/FIFO", 0777);
/* Open the FIFO */
fd = open("/tmp/FIFO", O_RDONLY | O_NONBLOCK);
/* Set async flag */
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC);
/* Set SETSIG flag to receive SIGIO signal */
fcntl(fd, F_SETSIG, 0);
/* Wait for SIGIO signal...*/
pause();
return 0;
}
--- code snippit ---