Bug 28383

Summary: screen incorrectly detects ptys with devfs
Product: Ports & Packages Reporter: Valentin Nechayev <netch>
Component: Individual Port(s)Assignee: Andrey A. Chernov <ache>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Valentin Nechayev 2001-06-24 09:40:01 UTC
When screen is built from ports on fresh -current system with devfs,
config.h contains:

#define PTYRANGE0 "pqrsPQRS"
#define PTYRANGE1 "0"

instead of correct

#define PTYRANGE0 "pqrsPQRS"
#define PTYRANGE1 "0123456789abcdefghijklmnopqrstuv"

This is caused by default screen testing which separates some special
cases (OSF, AIX,...), wide-spread /dev/ptmx variant, and without them
falls to simple BSD-styled case with iterative opening of all master
pty's in classes specified with PTYRANGE0 and PTYRANGE1.
Screen's configure gets values from PTYRANGE0 and PTYRANGE1 from listing
of current /dev, which works correct without devfs, but fails with devfs.

Example of result:

netch@iv:~>w
10:25AM  up 50 mins, 14 users, load averages: 0.00, 0.00, 0.00
USER             TTY      FROM              LOGIN@  IDLE WHAT
root             v1       -                 9:35AM    15 -sbash (sbash)
netch            v2       -                 9:35AM    26 -bash (bash)
netch            v3       -                 9:35AM    26 -bash (bash)
netch            v4       -                 9:35AM    30 -bash (bash)
netch            v6       -                 9:36AM    48 ssh -2 localhost
netch            p0       :ttyv7:S.0        9:35AM     - /usr/local/bin/mutt -y
netch            p1       localhost         9:36AM    48 -bash (bash)
netch            q0       :ttyv7:S.1        9:35AM     - w
netch            r0       :ttyv7:S.2        9:41AM    29 /usr/local/bin/mutt -y
netch            s0       :ttyv7:S.3        9:55AM    15 lynx http://www.inar.r
netch            P0       :ttyv7:S.4       10:08AM    11 lynx http://www.inar.r
netch            Q0       :ttyv7:S.5       10:08AM     - lynx http://www.inar.r
netch            R0       :ttyv7:S.6       10:09AM    15 lynx http://www.inar.r
netch            S0       :ttyv7:S.7       10:09AM    15 lynx http://www.inar.r

An attempt to create new terminal, either from the same metasession or
new one, fails with "No more PTYs." screen's error message.
Strange pty allocation pattern (shown in `w' output) points to its reason.

Fix: Disable misworked configure detecting of ptys and hardcode FreeBSD variant.
This also fixes need to reinstall screen when new ptys are generated
in plain old /dev, with little overhead of testing all nonexistent
ones when ptys are really exhausted.



/netch--E0OAjr7NHWWOJFgF7b0goWBNJ5yFLt5vepYGbdEiF4WARPDR
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

diff -rNu 0/Makefile 1/Makefile
--- 0/Makefile	Sat Mar 31 12:36:51 2001
+++ 1/Makefile	Sun Jun 24 11:30:58 2001
@@ -7,7 +7,7 @@
 
 PORTNAME=	screen
 PORTVERSION=	3.9.8
-PORTREVISION=	5
+PORTREVISION=	6
 CATEGORIES=	misc
 MASTER_SITES=	ftp://ftp.uni-erlangen.de/pub/utilities/screen/ \
 		${MASTER_SITE_GNU}
diff -rNu 0/files/patch-ah 1/files/patch-ah
--- 0/files/patch-ah	Thu Jan  1 03:00:00 1970
+++ 1/files/patch-ah	Sun Jun 24 11:23:56 2001
@@ -0,0 +1,80 @@
+--- configure.orig	Sun Jun 24 11:18:54 2001
++++ configure	Sun Jun 24 11:23:23 2001
+@@ -2183,76 +2183,10 @@
+ fi
+ rm -f conftest*
+ 
+-echo "checking for /dev/ptc" 1>&6
+-echo "configure:2213: checking for /dev/ptc" >&5
+-if test -r /dev/ptc; then
+-cat >> confdefs.h <<\EOF
+-#define HAVE_DEV_PTC 1
+-EOF
+-
+-fi
+-
+-echo "checking for SVR4 ptys" 1>&6
+-echo "configure:2222: checking for SVR4 ptys" >&5
+-if test -c /dev/ptmx ; then
+-cat > conftest.$ac_ext <<EOF
+-#line 2225 "configure"
+-#include "confdefs.h"
+-
+-int main() {
+-ptsname(0);grantpt(0);unlockpt(0);
+-; return 0; }
+-EOF
+-if { (eval echo configure:2232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+-  rm -rf conftest*
+-  cat >> confdefs.h <<\EOF
+-#define HAVE_SVR4_PTYS 1
+-EOF
+-
+-else
+-  echo "configure: failed program was:" >&5
+-  cat conftest.$ac_ext >&5
+-fi
+-rm -f conftest*
+-fi
+-
+-echo "checking for ptyranges" 1>&6
+-echo "configure:2246: checking for ptyranges" >&5
+-if test -d /dev/ptym ; then
+-pdir='/dev/ptym'
+-else
+-pdir='/dev'
+-fi
+-cat > conftest.$ac_ext <<EOF
+-#line 2253 "configure"
+-#include "confdefs.h"
+-#ifdef M_UNIX
+-   yes;
+-#endif
+-
+-EOF
+-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+-  egrep "yes" >/dev/null 2>&1; then
+-  rm -rf conftest*
+-  ptys=`echo /dev/ptyp??`
+-else
+-  rm -rf conftest*
+-  ptys=`echo $pdir/pty??`
+-fi
+-rm -f conftest*
+-
+-if test "$ptys" != "$pdir/pty??" ; then
+-p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
+-p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g'  | sort -u | tr -d '\012'`
+ cat >> confdefs.h <<EOF
+ #define PTYRANGE0 "pqrsPQRS"
++#define PTYRANGE1 "0123456789abcdefghijklmnopqrstuv"
+ EOF
+-
+-cat >> confdefs.h <<EOF
+-#define PTYRANGE1 "$p1"
+-EOF
+-
+-fi
+ 
+ echo "checking default tty permissions/group" 1>&6
+ echo "configure:2284: checking default tty permissions/group" >&5
How-To-Repeat: 
Close all ptys, rebuild screen from ports and check PTYRANGE* in config.h.
Comment 1 Mario Sergio Fujikawa Ferreira freebsd_committer freebsd_triage 2001-06-26 04:38:39 UTC
Responsible Changed
From-To: freebsd-ports->ache

Over to maintainer.
Comment 2 Andrey A. Chernov freebsd_committer freebsd_triage 2001-06-26 05:32:19 UTC
State Changed
From-To: open->closed

Fixed when screen upgrade to 3.9.9