Subject: Re: Review wsdisplay status device
To: Julio Merino <jmmv@hispabsd.org>
From: Gregory McGarry <g.mcgarry@ieee.org>
List: tech-kern
Date: 06/25/2002 08:31:05
Julio Merino wrote:
> > The only problem I can see is that you're reading the dynamic state
> > from the kernel. Once you return to userland, there is no guarantee
> > that the returned value is correct any more. You can tell if an
> > event occurred, but not infer any precise kernel state.
>
> Well, in fact this does not matter from the point of view of the mouse
> daemon. All I need to know is when events happen...
>
> Though I think that event's data is quite trustable. Can you explain
> why it may be wrong?
Your example code said this:
if (poll(pfd, 1, INFTIM) <= 0)
warn("failed");
read(fd, &evt, sizeof(evt));
/* XXX */
if (evt.type == WSCONS_EVENT_DISPLAY_SWITCH)
printf("New display: %d\n", evt.value);
Which isn't necessarily true. If the display is changed at /* XXX */
then evt will hold stale information and the printf() statement is
incorrect.
-- Gregory McGarry <g.mcgarry@ieee.org>