[CentOS] program to monitor USB keys

Tue Sep 18 19:13:08 UTC 2007
Garrick Staples <garrick at usc.edu>

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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20070918/514bc26c/attachment-0004.sig>