[comp.sys.sun] The "ws_read_indev error length %d" error

a.worsley@ditmela.cng.dit.CSIRO.au (Andrew Worsley) (03/02/90)

Recently some one added the following to his .login and caused a week and
a half of mystery and frustration (you need X11R[34]:

alias   xinit xinit; kbd_mode -a

Okay it resets the keyboard on the console. This means every key typed
causes an error message to appear in the console of the form
"ws_read_indev error length %d". Absolutely nothing will cause a key
stroke to be communicated to any of the windows. The mouse still works.
The only way out I know so far is to exit suntools. A suntools/X11 hacker
may know a way to return the keyboard back to a sensible state (I would
appreciate hearing about it if you do know). 

Our user in adding the above line to his .login had neglected to escape
the `;' consequently it would reset the keyboard of any Sun that he logged
into to! It took us ages to find out what was causing it. Unfortunately
Sun technicians here had never heard of this error message and so couldn't
shed any light on what the cause might be. It had to be tracked down by
trail and error. If you escape the ';' it is actually quite a sensible
alias as xinit can apparently leave you keyboard in a funny state
sometimes. So it is sensible to reset the keyboard after the program
exits.

I post this information so that any one else who finds the problem won't
have to spend so long tracking it down (I hope) and prehaps to persuade
Sun to somehow prevent any old user from stomping on the keyboard (or
screen) with unprivledged programs.

	Andrew Worsley
Division of Information Technology (Melbourne), Phone +61 3 347 8644
C.S.I.R.O.                                      Fax  +61 3 347 8987
55 Barry St.                                    Telex AA 152914
Carlton, Vic, 3053, Australia                   E-mail: worsley@ditmela.oz.au

david@eng.sun.com (03/08/90)

In article <5541@brazos.Rice.edu> a.worsley@ditmela.cng.dit.CSIRO.au
(Andrew Worsley) writes:
>X-Sun-Spots-Digest: Volume 9, Issue 72, message 9
>
>Recently some one added the following to his .login and caused a week and
>a half of mystery and frustration (you need X11R[34]:
>
>alias   xinit xinit; kbd_mode -a

If you run X from a SunView window instead of the console, you need to do
a kbd_mode -e instead of kbd_mode -a.

You should probably set up a shell script something like this...

#! /bin/sh
xinit
case "$WINDOW_PARENT" in
"") kbd_mode -a ;;
*) kbd_mode -e ;;
esac

This is still not foolproof, but it's an improvement.

David DiGiacomo, Sun Microsystems, Mt. View, CA  sun!david david@eng.sun.com

guy@uunet.uu.net (Guy Harris) (03/09/90)

>Recently some one added the following to his .login and caused a week and
>a half of mystery and frustration (you need X11R[34]:
>
>alias   xinit xinit; kbd_mode -a
>
>Okay it resets the keyboard on the console.

Yes, it does, but that's a side-effect of what it's intended to do...

>This means every key typed causes an error message to appear in the
>console of the form "ws_read_indev error length %d".

...which is to take the keyboard out of "encoded events" mode and put it
into "ASCII" mode.  The SunView kernel code expects the keyboard to be in
either encoded or unencoded events mode; i.e., it expects all the stuff
coming up from the keyboard to be in "Firm_event" format, i.e. an event
structure with time stamps and other stuff in it.  In ASCII mode, it sends
up ASCII characters, which are smaller than Firm_events and therefore
confuse the living hell out of the SunView kernel code.

>A suntools/X11 hacker may know a way to return the keyboard back to
>a sensible state (I would appreciate hearing about it if you do know). 

	kbd_mode -e

To quote from the KBD_MODE(1) manual page:

 SYNOPSIS
      kbd_mode [ -a -e -n -u ]

 DESCRIPTION
      Kbd_mode resets the  Sun  console  keyboard  to  a  rational
      state.

 OPTIONS
      The following options are supported, see kb(4S) for details:

      -a      Causes ASCII to be reported.

      -e      Causes Firm_events to be reported.

      -n      Causes up/down key codes to be reported.

      -u      Causes undecoded keyboard values to be reported.

Actually, the manual page is a *bit* misleading, since it implies (to me,
at least) that the "-whatever" options are actually optional.  In fact, it
does "require" that one be there, in that it prints a usage message if you
leave one out.  However, part of the usage message is a report on the
current state of the keyboard, so "kbd_mode" by itself tells you which
mode the keyboard is in.

phil@grumpy.cgrg.ohio-state.edu (Phil Ritzenthaler) (03/09/90)

> alias   xinit xinit; kbd_mode -a
> 
> Okay it resets the keyboard on the console. This means every key typed
> causes an error message to appear in the console of the form
> "ws_read_indev error length %d". Absolutely nothing will cause a key
> stroke to be communicated to any of the windows. The mouse still works.
> The only way out I know so far is to exit suntools. 

On a Sun 4/280 we are getting the same messages, but we are not using the
kbd_mode -a command.  I have called Sun about it, they suggested
increasing the users, the Stream data structures, and the NSTREAM
parameter.  I did this and installed the new kernel; it was a failure.

We are still getting ws_read_indev errors and it's getting more and more
frustrating.  Any ideas, you Sun Spotters??

Phil Ritzenthaler  The Advanced Computing Center for the Arts & Design (ACCAD)
Systems Manager    The Ohio State University
                   UUCP: ...!{pyramid,killer}!grumpy.cgrg.ohio-state.edu!phil
(614) 292-3416     ARPA: phil@grumpy.cgrg.ohio-state.edu