On Tue, Sep 18, 2007 at 01:41:32PM -0400, Jerry Geis alleged: > I wrote a small program to monitor keyboards found on /dev/input/event* > It works great but I always get EAGAIN from my read() function. google > says this is normal > when open() is used and O_NONBLOCK mode. Correct. EAGAIN is how you distinguish between a "real" error, and a normal nonblocking return. > I know this is slightly offtopic but I was wondering if the centos gurus > that also > program know anything about this. My goal was to not be eating CPU cycles > with a small program that just monitors key presses. With EAGAIN always > coming in > the process though small keeps waking up. > > Or perhaps there is another way to do this that I am not aware of. Typically, one opens the file or files and passes the file descriptors to select(2) or poll(2) to determine when they are ready for reading or writing. select(2) and poll(2) can do a neat idle for you.
Attachment:
pgpD83tGFt5P9.pgp
Description: PGP signature
_______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx http://lists.centos.org/mailman/listinfo/centos