Re: Async notification for fifos possible?

Richard B. Johnson (root@chaos.analogic.com)
Thu, 18 Feb 1999 09:42:25 -0500 (EST)


On Thu, 18 Feb 1999, Marc Bechler wrote:

> Hi all!
>
> Several programming (and reading) hours after trying to find an answer to
> my question I decided to write to this newsgroup.
>
> I would like to know if the current kernel supports an asynchronous
> notification for FIFOs. I interpreted the collected information about this

[SNIPPED]


>
> Here is what I implement on server side:
> ...
> fd = open("/tmp/hello.fifo", O_RDWR);
> ioctl(fd, FIOASYNC, &arg); // arg is 0
> fcntl(fd, F_SETFD, FASYNC);
> fcntl(fd, F_SETSIG, SIGIO);
> signal(SIGIO, sig_io); // where sig_io prints s.th to the stdout.
> ...
>

I think all you have to do is:
int flags = 1;
ioctl(fd, FIONBIO, &flags); /* Make non blocking */
flags = fcntl(fd, F_GETFL);
flags |= (FNDELAY|FASYNC);
fcntl(fd, F_SETFL, flags);
fcntl(fd, F_SETOWN, getpid() ); /* Send signals to me */
... and it will work (no typos are checked).

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.2.1 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
Wisdom : It's not a Y2K problem. It's a Y2Day problem.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/