Kernel events without kevents
Posted Mar 15, 2007 16:04 UTC (Thu) by
pphaneuf (guest, #23480)
In reply to:
Kernel events without kevents by felixfix
Parent article:
Kernel events without kevents
It behaves just like a real signal. You get at least one, but it's possible that you lose some due to overflow (the signal handler got EAGAIN and ignores it, giving similar behaviour). The reading end should read until EAGAIN, of course, to drain the pipe, before handling the signal (so that if another signal comes in, it is not missed). Of course, I also use something like a 1K buffer on the stack to "eat" the bytes, I don't read a single byte at a time.
If you really want to avoid this, you can have a bool set aside that you test before writing the byte, set to true when you did, and so on, but I prefer to let the kernel do all the book-keeping for me, I have plenty of other opportunities to screw up.
On a pipe, everything is contiguous. Unless you find a way to seek. ;-)
(
Log in to post comments)