[comp.windows.x] fixing Sun keyboard after X failure

ndd@duke.cs.duke.edu (Ned Danieley) (08/04/87)

We're considering going to X instead of SunView, and I've
run into a problem: if the X server dies unexpectly, the
associated keyboard is left in some strange state that renders
it unusable. This is especially bothersome when it happens on the
server. I have tried the fixKbd program that was recently posted
to this group, but it did not appear to have any affect. Does
anyone know how I can reset the keyboard short of rebooting?

Ned Danieley (ndd@sunbar.mc.duke.edu)
Basic Arrhythmia Laboratory
Duke University Medical Center
Durham, NC  27710
(919) 684-6807 or 684-6942

mende@aramis.rutgers.edu (Bob Mende) (08/04/87)

In article <9997@duke.cs.duke.edu> ndd@duke.cs.duke.edu (Ned Danieley) writes:
| We're considering going to X instead of SunView, and I've
| run into a problem: if the X server dies unexpectly, the
| associated keyboard is left in some strange state that renders
| it unusable. This is especially bothersome when it happens on the
| server. I have tried the fixKbd program that was recently posted
| to this group, but it did not appear to have any affect. Does
| anyone know how I can reset the keyboard short of rebooting?

  try invoking X with a command similar to

  xinit uwm ; setkeys reset

  This way the only way that the keyboard will get messed up if the
Machine crashes (then you dont have to worry about the keyboard) or if
the X server dies so badly that the second command dies.  I have only
had this happen to me once and I was issuing the command like this

  exec xinit uwm ; setkeys reset

  This way when I exit x it kills my lowest shell (yes ... a cheap way
to do it ... but it works.).  
  If your keyboard ever gets messed up (and you are on a network or
have an extra terminal connected to your sun) you can type "setkeys
reset" from any terminal on the system.  This is a good feature unless
your under X and someone does it to you.


					Bob
-- 
     mende@rutgers.edu    {...}!rutgers!mende    mende@pisces.bitnet

brisco@caip.rutgers.edu (Thomas Paul Brisco) (08/04/87)

In article <9997@duke.cs.duke.edu> ndd@duke.cs.duke.edu (Ned Danieley) writes:

> We're considering going to X instead of SunView, and I've
> run into a problem: if the X server dies unexpectly, the
> associated keyboard is left in some strange state that renders
> it unusable. This is especially bothersome when it happens on the
> server. I have tried the fixKbd program that was recently posted
> to this group, but it did not appear to have any affect. Does
> anyone know how I can reset the keyboard short of rebooting?
> 


	I've found that logging into the sun from the network (or any
other tty) and running "setkeys reset" will fix the problem most of
the time. (The only time I've had problems was in bringing up X11 and
*everything* was in a wierd state).

				Tp.
-- 
                  ----------------------------------------------------------
                  -                  ARPA: Brisco@rutgers                  -
                  -  UUCP: (ihnp4!ut-sally, allegra!packard) !caip!brisco  -
                  ----------------------------------------------------------

turner@daisy.UUCP (D'arc Angel) (08/08/87)

> Posted: Tue Aug  4 09:24:05 1987
> 
> We're considering going to X instead of SunView, and I've
> run into a problem: if the X server dies unexpectly, the
> associated keyboard is left in some strange state that renders
> it unusable. This is especially bothersome when it happens on the
> server. I have tried the fixKbd program that was recently posted
> to this group, but it did not appear to have any affect. Does
> anyone know how I can reset the keyboard short of rebooting?
> 
> Ned Danieley (ndd@sunbar.mc.duke.edu)
> Basic Arrhythmia Laboratory
> Duke University Medical Center
> Durham, NC  27710
> (919) 684-6807 or 684-6942

here's a program passed on to me from a kind soul as sequent..
----cut here--------cut here--------cut here--------cut here----
#!/bin/csh -f
#	runs X server and ensures keyboard doesn't hang
set oldkey = `kreset`
set server = X
cd ~
$server >& ,server
kreset $oldkey
---and here---and here---and here---and here---and here---and here
#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sundev/kbio.h>
#include <sundev/kbd.h>

main (argc, argv)
int     argc;
char   *argv[];
{
    int     oldtrans;
    int     newtrans;
    int     kfd;

    kfd = open ("/dev/kbd", O_RDWR);
    if (kfd < 0) {
	perror ("open");
	exit (-1);
    }

    if (ioctl (kfd, KIOCGTRANS, &oldtrans) < 0) {
	perror ("KIOCGTRANS");
	exit (-1);
    }
    printf ("%d\n", oldtrans);

    if (argc > 1) {
	newtrans = atoi (argv[1]);
	if (ioctl (kfd, KIOCTRANS, &newtrans) < 0) {
	    perror ("KIOCTRANS");
	    exit (-1);
	}
    }

    return (0);
}

-- 
C'est la vie, C'est la guerre, C'est la pomme de terre
{cbosgd,fortune,hplabs,seismo!ihnp4,ucbvax}!nsc!daisy!turner      Jim Turner 
Daisy Systems, 700 E. Middlefield Rd, P.O. Box 7006, 
Mountain View CA 94039-7006.                                   (415)960-0123