Disable VT switching under Linux

Hi,

I already did some research on the subject. The problem occurs when killing the SDL application and restarting it. When libSDL reaches the code where VT_WAITACTIVE is
issued the ioctl() never returns - in FB_EnterGraphicsMode().
We are seeing the problems when running SDL applications on Linux framebuffer (fbdev), not tested under X11 or another SDL video driver.

I can reproduce the case anytime with simple testpalette test that comes with libSDL in 1.2 branch on x86 and our embedded arch (cris):
$ ./configure --enable-video --enable-events --enable-video-fbcon --disable-everything-else-tm
$ make
$ make install
$ cd test && ./configure && make
$ cd test && sudo ./testpalette
$ # In another console I do: killall -9 testpalette
$ Killed
$ # now restart the app
$ cd test && sudo ./testpalette

Now the screen is not initialized and the strace output shows that we are currently waiting on VT_WAITACTIVE ioctl().

Is this a known issue with Linux console and VT?
How can this be overcome? I’ve found a ‘solution’ by sending signal 15 to the application and it would break out from VT_WAITACTIVE waiting and continue normally!??!

When running application on an embedded device there is not a chance to send a signal to the application, since there is no keyboard attached.

I’ve hacked the libSDL source a bit to not use VT switching at all. I’m wondering if this would solve the problems I’m seeing and not introduce other problems. Application is primarily targeted for the embedded environment, where no virtual terminals are present (again, no keyboard is attached) and user can’t switch between virtual terminals. That being said, can I avoid using VT_xxx ioctl()s that without breaking other stuff?

Patch:

Thank you,
Hinko–
Hinko Ko?evar, OSS developer
?ETRTA POT, d.o.o.
Planina 3, 4000 Kranj, SI EU
tel ++386 (0) 4 280 66 03
e-mail @Hinko_Kocevar
http www.cetrtapot.si

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: no_vt_switching_fbcon.diff
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20081204/54cc7b8c/attachment.txt

Hinko Kocevar wrote:

Hi,

I already did some research on the subject. The problem occurs when killing the SDL application and restarting it. When libSDL reaches the code where VT_WAITACTIVE is
issued the ioctl() never returns - in FB_EnterGraphicsMode().
We are seeing the problems when running SDL applications on Linux framebuffer (fbdev), not tested under X11 or another SDL video driver.

I can reproduce the case anytime with simple testpalette test that comes with libSDL in 1.2 branch on x86 and our embedded arch (cris):
$ ./configure --enable-video --enable-events --enable-video-fbcon --disable-everything-else-tm
$ make
$ make install
$ cd test && ./configure && make
$ cd test && sudo ./testpalette
$ # In another console I do: killall -9 testpalette
$ Killed
$ # now restart the app
$ cd test && sudo ./testpalette

Now the screen is not initialized and the strace output shows that we are currently waiting on VT_WAITACTIVE ioctl().

Is this a known issue with Linux console and VT?
How can this be overcome? I’ve found a ‘solution’ by sending signal 15 to the application and it would break out from VT_WAITACTIVE waiting and continue normally!??!

When running application on an embedded device there is not a chance to send a signal to the application, since there is no keyboard attached.

I’ve hacked the libSDL source a bit to not use VT switching at all. I’m wondering if this would solve the problems I’m seeing and not introduce other problems. Application is primarily targeted for the embedded environment, where no virtual terminals are present (again, no keyboard is attached) and user can’t switch between virtual terminals. That being said, can I avoid using VT_xxx ioctl()s that without breaking other stuff?

I’m not sure if above would work happily with fbcon…

I’ve found another solution. If instead of querying /dev/tty0, /dev/tty1 is used for VT_OPENQRY ioctl() the problem never occurs. This was observed in the tslib code. Here is the patch:
hinkok at alala /work/export/SDL-1.2 $ svn diff
Index: src/video/fbcon/SDL_fbevents.c===================================================================
— src/video/fbcon/SDL_fbevents.c (revision 4179)
+++ src/video/fbcon/SDL_fbevents.c (working copy)
@@ -246,7 +246,7 @@
{
/* Open only if not already opened */
if ( keyboard_fd < 0 ) {

  •   static const char * const tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
    
  •   static const char * const tty0[] = { "/dev/tty1", "/dev/vc/1", NULL };
      static const char * const vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
      int i, tty0_fd;
    

Can someone shed some light on why does such subtle change make so much difference?

Thank you,
Hinko


Hinko Ko?evar, OSS developer
?ETRTA POT, d.o.o.
Planina 3, 4000 Kranj, SI EU
tel ++386 (0) 4 280 66 03
e-mail @Hinko_Kocevar
http www.cetrtapot.si

Hinko Kocevar wrote:

Can someone shed some light on why does such subtle change make so much difference?

I’ve found some more info in this post, but it is still unclear
why this works like that, even after reading vt_ioctl.c source
code and comments:

https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/7228
http://rswiki.csie.org/lxr/http/source/drivers/char/vt_ioctl.c--
Hinko Ko?evar, OSS developer
?ETRTA POT, d.o.o.
Planina 3, 4000 Kranj, SI EU
tel ++386 (0) 4 280 66 03
e-mail @Hinko_Kocevar
http www.cetrtapot.si