Re: csh history and pts

From: Giorgos Keramidas <keramida_at_freebsd.org>
Date: Sun, 31 Aug 2008 23:48:35 +0300
On Sun, 31 Aug 2008 22:09:50 +0200, Ed Schouten <ed_at_80386.nl> wrote:
> Some people on IRC told me that (t)csh had some problems with "pty
> detection" with MPSAFE TTY, but grepping through the source and asking
> various people around the globe, I still have no idea what "pty
> detection" is and why (t)csh has the urge to "detect pty's".
>
> Maybe a (t)csh guru can help me out?

Yes, a bit of background is probably going to be useful...

tcsh enables autologout automatically to a default of 60 seconds in the
following cases:

    Set to `60' (automatic logout after 60 minutes, and no
    locking) by default in login and superuser shells, but not if
    the shell thinks it is running under a window system (i.e.,
    the DISPLAY environment variable is set), the tty is a
    pseudo-tty (pty) or the shell was not so compiled (see the
    version shell variable).

The `contrib/tcsh/sh.c' code implements this near line 456:

 456     if (loginsh || (uid == 0)) {
 457         if (*cp) {
 458             /* only for login shells or root and we must have a tty */
 459             if ((cp2 = Strrchr(cp, (Char) '/')) != NULL) {
 460                 cp2 = cp2 + 1;
 461             }
 462             else
 463                 cp2 = cp;
 464             if (!(((Strncmp(cp2, STRtty, 3) == 0) && Isalpha(cp2[3])) ||
 465                   Strstr(cp, STRslptssl) != NULL)) {
 466                 if (getenv("DISPLAY") == NULL) {
 467                     /* NOT on X window shells */
 468                     setcopy(STRautologout, STRdefautologout, VAR_READWRITE);
 469                 }
 470             }
 471         }
 472     }

The STRslptssl[] char array contains { '/', 'p', 't', 's', '/', '\0' },
in wide char format, and this is where the check for /dev/pts/xxx is
done.

By skimming through the code I haven't been able to see anything odd,
after the fix we installed in subversion change r172665:

------------------------------------------------------------------------
r172665 | mp | 2007-10-15 18:23:07 +0300 (Mon, 15 Oct 2007) | 6 lines

Import two vendor fixes from tcsh-6.15.01 for MFC to 7.0. The fixes are:
  - Fix pty detection for autologout setting
  - kill `foo` got stuck because sigchld was disabled too soon

Requested by: re
------------------------------------------------------------------------

I have an IRC log from scottl noting that he still got the default 60
second autologout, but this was on 6.X IIRC:

* scottl__ tries to remember how to turn off auto-logout
<motminh> scottl__: tcsh option - I guess tcsh can no longer determin
  activity post TTY?
<keramida> scottl__: I remember Kris mentioning an mpsafetty & tcsh
  issue.  I haven't had the time to go back and check if the pty-detection
  we fixed with kern.pts.enable=1 still works after mpsafetty
<motminh> scottl__:  what does echo $autologout say?
<scottl__> [y1] ~> echo $autologout
<scottl__> 60
<scottl__> on a 6.3 machine, I get
<scottl__> pooker] ~> echo $autologout
<scottl__> autologout: Undefined variable.

I can't reproduce this with a current from Aug 29, but this snapshot has
been built with the experimental 'packet mode' patch, and a few other
local changes, so I will have to try with a clean /head/ snapshot.

HTH,
Giorgos


Received on Sun Aug 31 2008 - 18:49:13 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:34 UTC