[comp.unix.questions] Pseudo-Terminals Forever

richr@etl.ARPA (Rich Rosenthal) (04/04/88)

    Just the facts...

    On a Macintosh I ran UW, the terminal emulation part of "UW, A
    Multiple-Window Terminal Emulator for Use with 4.nBSD 'UNIX'".

    On VAX BSD4.3 I ran UW and I created a couple of pseudo-terminals.

    I quit most of the pseudo-terminals using 'exit' or the Mac menu
    command to kill the window.

    For a change of pace, on one of the pseudo-terminals
    I exec'ed login and latter logged out.

    Result.  The account 'news' is still logged in 5 days latter, but,
    there are zero (0) processes associated with the login.

    I cannot kill any processes to terminate the login, so...

    How do I get rid of the appearance that 'news' is still logged in?

    Here is the output of 'w':

      8:19am  up 6 days, 17:47,  9 users,  load average: 0.18, 0.16, 0.22
    User     tty       login@  idle   JCPU   PCPU  what
    viet     tty22     7:27am    48      6      4  -tcsh 
    mike     tty21    Tue 1pm 3days   1:25     15  emacs m35.df 
    bill     tty29    Tue10am 5days     10      5  -tcsh 
    simental ttyp0     5:41am    29      8      6  -tcsh 
    tina     ttyp1     5:48am    40      5      4  -tcsh 
    richr    ttyp3     7:27am         1:56      2  w 
    news     ttyp4     7:29am    47      8      4  -csh 
    lukes    ttyp5     7:51am    11     34      4  -tcsh 
    news     ttyqe    Wed10am 5days                -

    The ps command shows no (0) processes associated with the news
    logged in on ttyqe.

    Thanks for the help.

-- 
Rich Rosenthal                                | richr@etl.arpa
US Army Engineer Topographic Laboratories     |
Fort Belvoir, Virginia 22060-5546             | (202) 355-2830

asa@unisoft.UUCP (Asa Romberger) (04/05/88)

In article <38@etl.ARPA> richr@etl.arpa. (Rich Rosenthal) writes:
>    For a change of pace, on one of the pseudo-terminals
>    I exec'ed login and latter logged out.
>
>    Result.  The account 'news' is still logged in 5 days latter, but,
>    there are zero (0) processes associated with the login.

I have had the same problem with a different psdeudo-terminal package.
The problem is probably that the programs that were running on the pseudo-
terminal managed to exit without cleaning up /etc/utmp. The only way that I
found to cure the problem was to write a program that looked for that entry
in /etc/utmp and clear the ut_type field.

chris@mimsy.UUCP (Chris Torek) (04/21/88)

[Another article to which I never saw a correct answer:]

In article <38@etl.ARPA> richr@etl.ARPA (Rich Rosenthal) writes:
>On VAX BSD4.3 I ran UW and I created a couple of pseudo-terminals.
>... on one of the pseudo-terminals I exec'ed login and latter logged out.
>Result.  The account 'news' is still logged in 5 days latter, but,
>there are zero (0) processes associated with the login.
>How do I get rid of the appearance that 'news' is still logged in?

By way of explanation:

The windows you create with UW have no associated login record
(unless UW runs setuid root so that it can write /etc/utmp and
/usr/adm/wtmp, which seems unlikely).  This is normal, if annoying.
Only true `login windows' have login records.

Now, when you ran login, it allowed the user `news' in on that pty,
so it wrote a login record in /usr/adm/wtmp and in /etc/utmp.
Normally, these records are replaced only by another `login' on
the same terminal (which writes a new one) or by /etc/init (which
erases the utmp entry and closes the wtmp one with a logout record)
when the process it spawned on that terminal finally exits.

Since UW was not run directly by init, init did not know to clear
the entry for ttyqe.

>    Here is the output of 'w':
>
>      8:19am  up 6 days, 17:47,  9 users,  load average: 0.18, 0.16, 0.22
>    User     tty       login@  idle   JCPU   PCPU  what
[stuff deleted]
>    news     ttyqe    Wed10am 5days                -
>
>    The ps command shows no (0) processes associated with the news
>    logged in on ttyqe.

Right---there is nothing there.  The easiest way to make the entry go
away is to use telnet or rlogin to log in many times, using up one pty
each time, until you take ttyqe.  Since rlogind and telnetd start at
ptyp0, if no one else is on, you may have to log in 30 times.  (Some
other program could be using ptypX, which would make this number smaller.)

Incidentally, rlogin and telnet login records are erased by rlogind and
telnetd, since init cannot do this for them.

(4.4BSD is likely to have a new method for deciding who is logged in,
etc., since the current system is starting to break down.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris