From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gatech.edu (gatech.edu [130.207.244.244]) by werple.mira.net.au (8.6.12/8.6.9) with SMTP id IAA24219 for ; Thu, 6 Jul 1995 08:53:03 +1000 Received: from math (math.skiles.gatech.edu) by gatech.edu with SMTP id AA01096 (5.65c/Gatech-10.0-IDA for ); Wed, 5 Jul 1995 18:54:17 -0400 Received: by math (5.x/SMI-SVR4) id AA26784; Wed, 5 Jul 1995 18:50:55 -0400 Resent-Date: Thu, 6 Jul 1995 00:38:33 +0200 (MET DST) Old-Return-Path: Message-Id: From: hoh@approve.se (Goran Larsson) Subject: SHTTY To: zsh-workers@math.gatech.edu Date: Thu, 6 Jul 1995 00:38:33 +0200 (MET DST) X-Mailer: ELM [version 2.4 PL23] Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Resent-Message-Id: <"BATS.0.MY6.DTn-l"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/154 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Hi. I have a problem with a change made to zsh between beta6 and beta9. zsh-2.6-beta6-hzoli4 ok zsh-2.6-beta9 problem zsh-2.6-beta10 problem zsh-2.6-beta10-hzolipre10 problem If I su to another user, e.g. root su:ing to news, then the zle option is unset and TTY is "". root # echo $TTY /dev/ttyp4 root # su news news $ echo $TTY news $ The reason can be found in init.c where SHTTY is opened with this code: if (isatty(0)) SHTTY = movefd(open(ttyname(0), O_RDWR)); else SHTTY = movefd(open("/dev/tty", O_RDWR)); In 2.5.01 and zsh-2.6-beta6-hzoli4 the code was: SHTTY = movefd((isatty(0)) ? dup(0) : open("/dev/tty", O_RDWR)); There is a VERY BIG difference between the old "dup(0)" and the new "open(ttyname(0), O_RDWR)" if the su:ed to user don't have permission to open the tty. In that case SHTTY is set to -1 and then the interactive part of zsh just falls apart. Why was this change made? I made this change and the expected behaviour was restored: ---->8-------->8-------->8-------->8-------->8-------->8-------->8---- *** init.c.dist Sat Jul 1 00:06:20 1995 --- init.c Thu Jul 6 00:27:34 1995 *************** *** 334,343 **** --- 334,347 ---- } /* Make sure the tty is opened read/write. */ + #if 1 /* HoH */ + SHTTY = movefd((isatty(0)) ? dup(0) : open("/dev/tty", O_RDWR)); + #else if (isatty(0)) SHTTY = movefd(open(ttyname(0), O_RDWR)); else SHTTY = movefd(open("/dev/tty", O_RDWR)); + #endif if (SHTTY != -1) { #if defined(JOB_CONTROL) && defined(TIOCSETD) && defined(NTTYDISC) ---->8-------->8-------->8-------->8-------->8-------->8-------->8---- -- Goran Larsson Phone: +46 13 299588 FAX: +46 13 299022 Approve AB +46 589 12810 +46 589 16901 hoh@approve.se I was an atheist, until I found out I was God.