NetBSD Problem Report #16901

Received: (qmail 24855 invoked from network); 19 May 2002 17:57:07 -0000
Message-Id: <200205191757.g4JHv5I10507@arresum.veego.de>
Date: Sun, 19 May 2002 19:57:05 +0200 (CEST)
From: bernd@arresum.inka.de
Reply-To: bernd@arresum.inka.de
To: gnats-bugs@gnats.netbsd.org
Subject: screen needs to be modified to use openpty(3)
X-Send-Pr-Version: 3.95

>Number:         16901
>Category:       pkg
>Synopsis:       screen needs to be modified to use openpty(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 19 17:58:01 +0000 2002
>Closed-Date:    Tue May 21 17:58:43 +0000 2002
>Last-Modified:  Thu Dec 30 23:30:02 +0000 2021
>Originator:     Bernd Ernesti
>Release:        NetBSD 1.5ZC
>Organization:

>Environment:


System: NetBSD 1.5ZC
Architecture: i386
Machine: i386
>Description:
	screen knows nothing about the new tty naming convention in NetBSD.

	So you can't use screen on a system with more the 16 open ttys.
>How-To-Repeat:
	Remove the old device nodes, which are no longer created by the
	default MAKEDEV target.

	Now open more then 16 sessions and try to use screen and notice the error
	message you get from it: No more PTYs. That happens when you had enough
	ptys remaining to open screen but no more to open another screen window.
>Fix:
	Change pty.c so it uses openpty(3).
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: tron 
State-Changed-When: Mon May 20 13:26:43 PDT 2002 
State-Changed-Why:  
Using the following diffs as "patches/patch-aa" will change "screen" to use 
opentty(3): 

--- pty.c.orig	Mon Feb 11 13:44:18 2002 
+++ pty.c	Mon May 20 22:11:34 2002 
@@ -318,6 +318,31 @@ 

/***************************************************************/ 

+#if defined(__NetBSD__) && !defined(PTY_DONE) 
+#define PTY_DONE 
+ 
+#include <sys/param.h> 
+#include <util.h> 
+ 
+int 
+OpenPTY(ttyn) 
+char **ttyn; 
+{ 
+  int f, s; 
+ 
+  if (openpty(&f, &s, TtyName, NULL, NULL) < 0) 
+    return -1; 
+  close(s); 
+ 
+  initmaster(f); 
+  *ttyn = TtyName; 
+ 
+  return f; 
+} 
+#endif 
+ 
+/***************************************************************/ 
+ 
#ifndef PTY_DONE 
int 
OpenPTY(ttyn) 

However for some unknown reason it doesn't work reliable unless I add a call 
to sleep(2) which sleeps at least one second before calling initmaster(). 
State-Changed-From-To: analyzed->closed 
State-Changed-By: tron 
State-Changed-When: Tue May 21 10:56:25 PDT 2002 
State-Changed-Why:  
I rewrote the openpty(3) support to fit better into screen's pty handling. 
Creating new windows now works reliable. 
From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/16901 CVS commit: pkgsrc/misc/screen
Date: Sat, 15 Sep 2012 09:14:53 +0000

 Module Name:	pkgsrc
 Committed By:	apb
 Date:		Sat Sep 15 09:14:53 UTC 2012

 Modified Files:
 	pkgsrc/misc/screen: Makefile distinfo
 	pkgsrc/misc/screen/patches: patch-aa

 Log Message:
 Move the NetBSD-specific part of screen's pty.c to the right place.

 This commit changes patch-aa so that the patched version
 of pty.c contains:

     ... other OS-specific code
     ... NetBSD-specific openpty() code (from patch-aa)
     ... generic openpty() code
     ... last resort code

 instead of the previous:

     ... other OS-specific code
     ... generic openpty() code
     ... NetBSD-specific openpty() code (from patch-aa)
     ... last resort code

 History behind this problem:

 The NetBSD-specific openpty() code was added in revision 1.1
 of misc/screen/patches/patch-aa.  (See PR pkg/16901.)  At that
 time, pkgsrc used screen-3.9.11, and the upstream version of
 screen did not use openpty() at all.  The patch added an "#if
 defined(__NetBSD__)" block as the last OS-specific section in
 pty.c, which then had:

     ... other OS-specific code
     ... NetBSD-specific openpty() code (from patch-aa)
     ... last resort code

 In screen-3.9.15, upstream added code in pty.c to use openpty().
 This was imported to pkgsrc on 2003-03-15.  At that time, pkgsrc's
 patch-aa accidentally inserted the NetBSD-specific code below
 instead of above the new code, so the patched version of pty.c
 had:

     ... other OS-specific code
     ... generic openpty() code         (from upstream)
     ... NetBSD-specific openpty() code (from patch-aa)
     ... last resort code

 The above is obviously wrong because the generic openpty() code
 would be used instead of the NetBSD-specific code, assuming
 HAVE_OPENPTY was defined by the configure script.

 This problem was reported in PR pkg/25317, but the patch in the PR
 was not understood so it was not applied.

 This commit changes patch-aa so that the patched version of pty.c
 contains:

     ... other OS-specific code
     ... NetBSD-specific openpty() code (from patch-aa)
     ... generic openpty() code         (from upstream)
     ... last resort code

 However, it still doesn't work on NetBSD with ptyfs mounted.


 To generate a diff of this commit:
 cvs rdiff -u -r1.83 -r1.84 pkgsrc/misc/screen/Makefile
 cvs rdiff -u -r1.32 -r1.33 pkgsrc/misc/screen/distinfo
 cvs rdiff -u -r1.10 -r1.11 pkgsrc/misc/screen/patches/patch-aa

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/16901: screen needs to be modified to use openpty(3)
Date: Fri, 31 Dec 2021 02:29:51 +0300

 Can this workaround be g/c'ed now?  We have /dev/ptmx for ages so
 screen detects NetBSD as HAVE_SVR4_PTYS.

 $ nm screen | grep 'openpty\|grantpt'
                  U grantpt

 -uwe

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.