jlp@cs.utah.edu (Jan L. Peterson) (12/20/88)
Greetings, I've had several people ask for the cleartty program, but can't remember where I got it or find the source code (too many piles of stuff to wade through on my desk). Anyway, I've written a new one that should do the same thing and am enclosing it here: ____________________cut here____________________ #! /bin/sh # standard shar file using sed, this shar ends with an exit so you # don't need to worry about the signature. # sed -e 's/^X//' > utmp_clear.c << 'SHAR_EOF' X#include <utmp.h> X#include <stdio.h> X XFILE *utmp_file; Xchar *progname; X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X progname = *argv; X X utmp_file = fopen("/etc/utmp", "rw"); X if (!utmp_file) X err("Couldn't open utmp."); X X while (--argc) X doit(*(++argv)); X X fclose(utmp_file); X} X Xdoit(tty_line) Xchar *tty_line; X{ X struct utmp u; X long where; X X rewind(utmp_file); /* start at the beginning */ X where = ftell(utmp_file); X while (fread(&u, sizeof(u), 1, utmp_file)) X if (strcmp(u.ut_line, tty_line) == 0) X { /* found a match */ X u.ut_line[0] = '\0'; X fseek(utmp_file, where, 0); X fwrite(&u, sizeof(u), 1, utmp_file); X return; /* a given tty should be here only once */ X } X else X where = ftell(utmp_file); X /* hit eof without matching */ X return; X} SHAR_EOF exit 0 ____________________cut here____________________ I hope this helps some people out. However, I had a phone call yesterday from evan@ssyx.ucsc.edu and he was having the problem, but the w(1) command didn't show a job of "-", so maybe there's more to this than meets the eye. Another temporary fix that seems to work is to use w(1) to find out what the last pty being used is, then move the next one in line to something else. (I.e., if the last line from w(1) says it's tty is ttyq7, mv /dev/ttyq8 /dev/bttyq8.) This at least will let you start your shelltool or rlogin. Note, however, that you have to be able to find a root window on the system to do this. Then, after rebooting, mv the bad one back. I havn't been able to determine if it's the same pty that is causing the problem. Come on, Sun, let's hear something from you? Or is this going to be another one of those "Fixed in the next release of the operating system" things we're all so fond of? BTW, I seem to remember getting cleartty from an issue (not the archive) of sun-spots. It would be volume five or earlier. -jan- -- Jan L. Peterson UUCP: { ...!utah-cs!caeco | quad1 }!olyis!jlp Mail: Olympus Software, Inc.; 1333 E 9400 S; Sandy, UT 84093 (USA) Phone: +1 801 572 1610