Subject: Re: Getting active console
To: Julio Merino <jmmv@hispabsd.org>
From: Matthew Mondor <mmondor@gobot.ca>
List: tech-kern
Date: 05/26/2002 14:42:44
On Tue, 28 May 2002 20:47:03 +0200
Julio Merino <jmmv@hispabsd.org> wrote:

 
> Retaking my mouse patch, I think we can avoid the need to include
> the WSDISPLAY_STIOF ioctl, which writes a character to the active
> console.

> 1. Use WSDISPLAY_GETACTIVENO to get active console number.
> 2. Open /dev/ttyE?, where ? is the value returned before.
> 3. Call TIOCSTI on the opened file descriptor.
> 4. Close the file.

Hmm isn't there a potential race condition since the active console has to
first be queried prior to opening? (maybe not for a single operation like
writing, but here we need read/write access to highlight/copy/paste
capabilities)... What happens if the mouse is currently moving, button
pressed, while current tty is swapped? (theoretically it could continue
working on the previous tty, unless it closes it and reiterates the main
loop)...

Just suggesting to take into account all scenarios in order to never have
to cope with possible undefined behavior.

Matt