Why does `ioctl(fd, EVIOCGRAB, 1)` cause key spam sometimes?
问题 I'm trying to write my own "keyboard driver" (without actually writing a kernel module), by grabbing the keyboard at what I assume is the lowest level of abstraction in userland: /dev/input/event* . The following code does the grabbing, provided you change the first ocurrence of ioctl(fd, EVIOCGRAB, UNGRAB) to ioctl(fd, EVIOCGRAB, GRAB) . // gcc main.c -o main #include <stdio.h> #include <unistd.h> #include <string.h> #include <linux/input.h> #include <fcntl.h> #include <errno.h> #define EXIT