Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 May 2001 01:34:27 -0700
From:      Peter Wemm <peter@wemm.org>
To:        David Wolfskill <david@catwhisker.org>
Cc:        current@FreeBSD.ORG, phk@FreeBSD.ORG
Subject:   Re: Huh??!? xterm: Error 14, errno 2: No such file or directory 
Message-ID:  <20010515083427.A1AAA3811@overcee.netplex.com.au>
In-Reply-To: <200105142019.f4EKJGA75484@bunrab.catwhisker.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
David Wolfskill wrote:

> Built -CURRENT & rebooted after mergemaster as usual, and some X
> applications (xbattbar; xlockmore; oclock) work OK, but no xterm.  At
> least, not from X (XF86-4.0.3).  I tried using Ctl-Alt-F2 to get to
> a non-X login, logged in , set DISPLAY to m147:0.0, issued "xterm &",
> and got an xterm OK.

Known problem.  phk changed the semantics of /dev/tty in the most recent
commits.  Traditional behavior for a process *without* a controlling tty
when it opens /dev/tty is to get ENXIO.

Formerly, ctty_open() returns ENXIO:
cttyopen(dev, flag, mode, p)
{
        struct vnode *ttyvp = cttyvp(p);

        if (ttyvp == NULL)
                return (ENXIO);
...


and now:
ctty_clone(void *arg, char *name, int namelen, dev_t *dev)
{
        struct vnode *vp;

        if (*dev != NODEV)
                return;
        if (strcmp(name, "tty"))
                return;
        vp = cttyvp(curproc);
        if (vp == NULL)
                return;  <<< here, leads to ENOENT.
        *dev = vp->v_rdev;
}

There used to be a device for the ctty.  We still maintain it for the
non-devfs case.  The following hack may work, I have not tested or even
compiled it:

Index: kern/tty_tty.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/tty_tty.c,v
retrieving revision 1.34
diff -u -r1.34 tty_tty.c
--- tty_tty.c	2001/05/14 08:22:56	1.34
+++ tty_tty.c	2001/05/15 08:30:17
@@ -177,6 +177,8 @@
 
 static void ctty_clone __P((void *arg, char *name, int namelen, dev_t *dev));
 
+static dev_t ctty;
+
 static void
 ctty_clone(void *arg, char *name, int namelen, dev_t *dev)
 {
@@ -187,9 +189,11 @@
 	if (strcmp(name, "tty"))
 		return;
 	vp = cttyvp(curproc);
-	if (vp == NULL)
-		return;
-	*dev = vp->v_rdev;
+	if (vp == NULL) {
+		if (ctty)
+			*dev = ctty;
+	} else
+		*dev = vp->v_rdev;
 }
 
 
@@ -201,6 +205,7 @@
 
 	if (devfs_present) {
 		EVENTHANDLER_REGISTER(dev_clone, ctty_clone, 0, 1000);
+		ctty = make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "ctty");
 	} else {
 		make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "tty");
 	}

This hack recreates a /dev/ctty hook that works the "old way", and makes
/dev/tty switch through to that one instead.  This is evil and is probably
even more broken than before, but I think it will work.

The alternative is to edit the XFree86 xterm source and rebuild it.
look for xc/programs/xterm/main.c where it opens /dev/tty and then
checks an inclusive list of errno's, including ENXIO and ENODEV etc.
Add ENOENT to the list of 'acceptable' errors.

Incidently, the xterm binary is broken, it does not use libutil/openpty().

Cheers,
-Peter
--
Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au
"All of this is for nothing if we don't go to the stars" - JMS/B5


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010515083427.A1AAA3811>