SUMMARY: user logins that won't die

From: Demetrios Stellas (
Date: Fri Sep 18 1992 - 05:49:23 CDT

Hi Again:

I would like to thank all who responded (too many to list).
The cause of the problem is that if you have windows open (sunview
or OW) and you exit without quitting all of your cmdtools and shelltools
they will leave an entry in /etc/utmp.

Since there were as many people interested in the solution as
there were respondents with suggestions..............

Here are two programs that will help clear the offending file
and an patch of the OS that may elimanate the problem all together.

Thanks Again to Everyone

From: Todd Pfaff <uunet!!todd>

Try the following C program.

 * From Sun-Spots Digest, v6n9 (Fri 29 Jan 1988)
 * Date: Wed, 20 Jan 88 11:37:51 EST
 * From: Graham Campbell <>
 * Subject: Program to help keep utmp clean
 * Since the question of cleaning out the pseudo-tty entries from utmp has
 * arisen again (Sun-Spots v6n5), I will contribute a small program that I
 * run from my .logout that does this.
 * Graham
#include <utmp.h>
#include <sys/file.h>
#include <stdio.h>
char master[11] = "/dev/pty??";

    struct utmp ut;
    int utmp, pty;
    long posn;

    utmp = open("/etc/utmp", O_RDWR);
    if (utmp == -1)
        perror("Cannot open utmp");
        exit (1);
    while (posn = lseek(utmp, 0L, L_INCR), read(utmp, &ut, sizeof(ut)) != 0)
        if (ut.ut_name[0] == 0)
        if (strncmp(ut.ut_line, "tty", 3) == 0 && (ut.ut_line[3] == 'p' ||
                           ut.ut_line[3] == 'q' || ut.ut_line[3] == 'r'))
            master[8] = ut.ut_line[3];
            master[9] = ut.ut_line[4];
            pty = open(master, O_RDWR);
            if (pty >= 0)
                lseek(utmp, posn, L_SET);
                ut.ut_name[0] = 0;
                ut.ut_host[0] = 0;
                write(utmp, &ut, sizeof(ut));

Todd Pfaff                     \ Internet:
Dept. of Mechanical Engineering \   Voice: (416) 525-9140 x2902
McMaster University              \    FAX: (416) 572-7944
1280 Main Street West             \
Hamilton, Ontario, CANADA  L8S 4L7 \

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

From: uunet!athena.Qualcomm.COM!phillips (Marc Phillips)

Write a program to clear out /etc/utmp entries. A 'man utmp' should get you started. I will put a copy of 'c' source code below which should do it for you if you don't want to write your own.

Marc Phillips

#include <stdio.h> #include <utmp.h> #include <fcntl.h> #include <sys/types.h> #include <unistd.h>

main(argc, argv) int argc; char **argv; { int res; int ufile; long entry_size = sizeof(struct utmp); struct utmp utmp_entry;

if ((ufile = open("/etc/utmp", O_RDWR)) < 0) { fprintf(stderr, "Unable to open or modify file\n"); exit(1); }

while (*++argv != NULL) { res = lseek(ufile, 0L, SEEK_SET); while (read(ufile, &utmp_entry, entry_size) != 0) { if (utmp_entry.ut_name[0] != 0 || utmp_entry.ut_host[0] != 0) printf("%-8.8s %-8.8s %-16.16s %x\n", utmp_entry.ut_line, utmp_entry.ut_name, utmp_entry.ut_host, utmp_entry.ut_time); if (strncmp(*argv, utmp_entry.ut_line, 8) == 0) { utmp_entry.ut_name[0] = 0; utmp_entry.ut_host[0] = 0; /* printf("Res = %x\n", res); */ res = lseek(ufile, -entry_size, SEEK_CUR); /* printf("Res = %x\n", res); */ res = write(ufile, &utmp_entry, entry_size); /* printf("res = %x\n", res); */ printf("*%-8.8s %-8.8s %-16.16s %x\n", utmp_entry.ut_line, utmp_entry.ut_name, utmp_entry.ut_host, utmp_entry.ut_time); } } }

exit(0); }

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

From: Christian Sebeke <uunet!!cseb>

I had a question sounding nearly the same posted to comp.sys.sun.admin. So I will include an extended summary for you. Another fellow manager suggested to simply remove the utmp-file, it gets rebuilt at the next login/logout. I have not tried this brute method right now.

Here is the summary:

----- Begin Included Message ----- >From (Christian Sebeke) Subject: SUMMARY: Pseudo Terminals Date: Thu, 27 Aug 1992 14:51:04 GMT

Thanks to all who replied: flash!!mnejat@uunet.UU.NET

The solution for me was manipulating the corrupted /etc/utmp - file with the program written by DaviD W. Sanderson ( It is available from comp.sources.unix (ask archie for the server next to you) in Volume 25.

MAKEDEV/mknod did not help because the utmp-file seems to be unaffected by this command.

Mehregan mentioned that there might be a patch for this behaviour. found a patch. His mail is included at the end of this text. The bugID could be 1040722.

The original posting was:

-----------CUT------------ Sometimes when I log into one of our SUN's and ask 'who', I get something like

User tty login@ idle JCPU PCPU what cseb ttyp2 8:40am w xbey ttyp6 14Aug9210days -

xbey does not have any processes running. It seems as if the Pseudo Terminal is not released correctly. I looked through the answerbook, manuals and FAQs - nothing found.

How can I free ttyp6 ?

Setup: several SPARCs, 4.1.2, OW3, occasionally SUNVIEW

-----------CUT------------ -----------CUT------------ This patch may fix what you've been seeing. Here's an excerpt from the README file. The patch itself is available at in /pub/misc/sun/sun-fixes/100188-02.tar.Z.

Patch-ID# 100188-02 Keywords: TIOCCONS re-direction security console pty Synopsis: SunOS 4.1.1;4.1.2: pty can get output from another application Date: 28/Feb/92 SunOS release: 4.1.1, 4.1.2 Unbundled Product: Unbundled Release: Topic: BugId's fixed with this patch: 1008324 1040722 1070495 Architectures for which this patch is available: sun3 sun3x sun4 sun4c sun4m Patches which may conflict with this patch: 100187-01, 100414-01 (obsoleted) Obsoleted by: Problem Description: This patch combines 3 fixes: 1. TIOCCONS can be used to re-direct console output/input away from "console" (bugIDs 1008324) 2. Kernel programs using pty can get output from previous application. (Formerly patch 100414-01, bugID 1070495) 3. Process not letting go of a pty (bugID 1040722) Patch contains kernel object modules for: cons.o tty_pty.o zs_async.o mcp_async.o mti.o -----------CUT------------

----- End Included Message -----

Hope this helps.



------------------------------------------------------------------------------- Christian Sebeke U. Hannover, LFI Schneiderberg 32 Phone: +49 511 762 5035 D-3000 Hannover 1 FAX: +49 511 762 5051 -------------------------------------------------------------------------------

From: Roy Richter PH/32 <uunet!!rrichter>

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:50 CDT