[comp.unix.wizards] Sun pty problem

sethr@cunixc.cc.columbia.edu (Seth Robertson) (03/27/89)

Hello.

I have a network of Suns (4.0) which are having troubles with their
ptys.  What happens is that when people use a pty (via sunview or
rlogin, and usually only ttyp0) it sometimes translates all of the
characters into ^Ds, thus logging them out.  This occurs *only* if
they use csh.  If the use ksh, ^C and ^Z don't work, and if they
su to an account that does use csh, the characters are again translated
into ^Ds.

I believe that this is somehow connected with the fact that background
jobs are running under that pty (i.e. user joe started a job with csh
in the background, then use schmo logs in and has this trouble), but it
is certainly possable to have jobs running in the background that *don't*
cause this behavior.

If anyone can help me, please give me a buzz...


						-Seth
						 seth@ctr.columbia.edu

guy@auspex.UUCP (Guy Harris) (03/28/89)

>What happens is that when people use a pty (via sunview or
>rlogin, and usually only ttyp0) it sometimes translates all of the
>characters into ^Ds, thus logging them out.

The pseudo-tty has gotten into "half-remote" mode; the bug that causes
this has been reported to Sun, along with a fix, and the fix will be in
a future release.  If you have source, you can fix it by having the
pseudo-tty *controller* "open" routine check whether the slave is open
(i.e., check whether there is a stream active on the slave side), and
send an M_CTL message with MC_DOCANON as its contents up that stream.

If you don't have source, the attached shell archive contains a program
that takes the pathname for the pseudo-tty *controller* (*not* slave -
e.g., hand it "/dev/ptyp0" rather than "/dev/ttyp0") and fixes it.  The
pseudo-tty controller must *not* be open (i.e., no "shelltool" or
"cmdtool" or "in.rlogind" or "in.telnetd" or... can be using it), since
pseudo-tty controllers are single-use devices.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  fixup.c
# Wrapped by guy@auspex on Mon Mar 27 12:19:23 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'fixup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fixup.c'\"
else
echo shar: Extracting \"'fixup.c'\" \(980 characters\)
sed "s/^X//" >'fixup.c' <<'END_OF_FILE'
X#include <stdio.h>
X
Xextern int	fprintf();
X
X#include <fcntl.h>
X
Xextern int	open();
X
X#include <sys/termio.h>
X
Xextern int	ioctl();
X
X#include <errno.h>
X
Xextern void	perror();
Xextern void	exit();
X
Xstatic char	*strerror();
X
Xint
Xmain(argc, argv)
X	int argc;
X	char **argv;
X{
X	register int fd;
X	int zero = 0;
X
X	if (argc != 2) {
X		(void) fprintf(stderr, "Usage: fixup pseudo-tty\n");
X		return 1;
X	}
X
X	if ((fd = open(argv[1], O_RDWR)) < 0) {
X		(void) fprintf(stderr, "fixup: Can't open %s: %s\n", argv[1],
X		    strerror(errno));
X		return 1;
X	}
X
X	if (ioctl(fd, TIOCREMOTE, &zero) < 0) {
X		(void) fprintf(stderr, "fixup: Can't fix %s: %s\n", argv[1],
X		    strerror(errno));
X		return 1;
X	}
X
X	return 0;
X}
X
Xstatic char *
Xstrerror(errnum)
X	int errnum;
X{
X	extern int sys_nerr;
X	extern char *sys_errlist[];
X	static char msg[6+10+1];	/* "Error "+number+'\0' */
X
X	if (errnum < 0 || errnum > sys_nerr) {
X		(void) sprintf(msg, "Error %d", errnum);
X		return msg;
X	} else
X		return sys_errlist[errnum];
X}
END_OF_FILE
if test 980 -ne `wc -c <'fixup.c'`; then
    echo shar: \"'fixup.c'\" unpacked with wrong size!
fi
# end of 'fixup.c'
fi
echo shar: End of shell archive.
exit 0