Subject: Controlling-tty semantics, and Ultrix emulation xterm
To: None <port-pmax@sun-lamp.cs.berkeley.edu>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: port-pmax
Date: 09/02/1994 12:21:23
I've run into a problem with controlling tty semantics. I've got
a native init, getty, login, and tcsh running on NetBSD.
I often try and start an xterm on the NetBSD machine, to get an X
window on a machine with a window system. This worked fine when I did
it from a session on the NetBSD box running from an Ultrix shell. But
when I try it now, with the native binaries, the (Ultrix) xterm fails;
and prints a message indicating it's failed to open /dev/tty ,
incurring an EPERM error.
Xterm currently exits when it sees such an error. The following
patch fixes it; but it's rather ugly.
I wonder if the right thing to do is to "fix" binary emulation to support
something closer to old Berkeley semantics of opening dev/tty; or
to hack on Xterm?
------
*** /tmp/RCSAa01793 Fri Sep 2 12:18:31 1994
--- X11/R6/xc/programs/xterm/main.c Fri Sep 2 12:07:09 1994
***************
*** 1660,1703 ****
* that has gone away). Simply make up some reasonable
* defaults.
*/
signal(SIGALRM, hungtty);
alarm(2); /* alarm(1) might return too soon */
if (! setjmp(env)) {
tty = open ("/dev/tty", O_RDWR, 0);
alarm(0);
} else {
tty_got_hung = True;
tty = -1;
errno = ENXIO;
}
signal(SIGALRM, SIG_DFL);
/*
* Check results and ignore current control terminal if
* necessary. ENXIO is what is normally returned if there is
* no controlling terminal, but some systems (e.g. SunOS 4.0)
* seem to return EIO.
*/
if (tty < 0) {
if (tty_got_hung || errno == ENXIO || errno == EIO ||
! errno == ENOTTY) {
no_dev_tty = TRUE;
#ifdef TIOCSLTC
ltc = d_ltc;
#endif /* TIOCSLTC */
#ifdef TIOCLSET
lmode = d_lmode;
#endif /* TIOCLSET */
#ifdef USE_SYSV_TERMIO
tio = d_tio;
#else /* not USE_SYSV_TERMIO */
sg = d_sg;
tc = d_tc;
discipline = d_disipline;
#ifdef sony
jmode = d_jmode;
jtc = d_jtc;
#endif /* sony */
#endif /* USE_SYSV_TERMIO */
} else {
SysError(ERROR_OPDEVTTY);
--- 1660,1705 ----
* that has gone away). Simply make up some reasonable
* defaults.
*/
signal(SIGALRM, hungtty);
alarm(2); /* alarm(1) might return too soon */
if (! setjmp(env)) {
tty = open ("/dev/tty", O_RDWR, 0);
alarm(0);
} else {
tty_got_hung = True;
tty = -1;
errno = ENXIO;
}
signal(SIGALRM, SIG_DFL);
/*
* Check results and ignore current control terminal if
* necessary. ENXIO is what is normally returned if there is
* no controlling terminal, but some systems (e.g. SunOS 4.0)
* seem to return EIO.
+ * (XXX) NetBSD emulation returns EPERM, because on 4.4BSD
+ * opening a tty doesn't make it a a controlling tty.
*/
if (tty < 0) {
if (tty_got_hung || errno == ENXIO || errno == EIO ||
! errno == ENOTTY || errno == EPERM) {
no_dev_tty = TRUE;
#ifdef TIOCSLTC
ltc = d_ltc;
#endif /* TIOCSLTC */
#ifdef TIOCLSET
lmode = d_lmode;
#endif /* TIOCLSET */
#ifdef USE_SYSV_TERMIO
tio = d_tio;
#else /* not USE_SYSV_TERMIO */
sg = d_sg;
tc = d_tc;
discipline = d_disipline;
#ifdef sony
jmode = d_jmode;
jtc = d_jtc;
#endif /* sony */
#endif /* USE_SYSV_TERMIO */
} else {
SysError(ERROR_OPDEVTTY);
------------------------------------------------------------------------------