I'm trying to better understand (conceptually) how a system like X works. My understanding is that for X to receive keyboard events, it has an internal event loop which performs a blocking read on /dev/input/event0
, for example, which the kernel exposes as a way to read user input. It then takes that event, does some processing (in userspace) and hands it off to the active window using some form of an event queue. Please correct me if I'm mistaken with how this essentially works.
But here's where I'm confused. If /dev/input/event0
or eventXX
is being read directly by X and hence those events are being consumed, how is it possible to have other processes performing reads on eventXX
? We can have a Python process read from the device, we can read from the command line, etc.
My understanding (and this could be where I'm wrong) is that a character device's output gets consumed by a single process, so if two processes were read
ing from /dev/...
then only one read
call would return with the given data. So if X is grabbing all the data from the character device, how are other processes able to read the same keyboard data?