From owner-freebsd-bugs Sun Jan 26 8:56:26 2003 Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D310037B401 for ; Sun, 26 Jan 2003 08:56:24 -0800 (PST) Received: from mail1.arcor-ip.de (mail1.arcor-ip.de [145.253.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 38FF643E4A for ; Sun, 26 Jan 2003 08:56:19 -0800 (PST) (envelope-from lucius@infos.com) Received: from chasey.wg (213.23.55.23) by mail1.arcor-ip.de (5.5.034) id 3E1E87630010CEA6 for freebsd-bugs@freebsd.org; Sun, 26 Jan 2003 17:56:13 +0100 Date: Sun, 26 Jan 2003 18:00:31 +0100 (CET) From: Friedemann Becker X-X-Sender: lucius@chasey.wg To: freebsd-bugs@freebsd.org Subject: Re: bin/47136: Message-ID: <20030126173949.D1679@chasey.wg> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org I found, that sh uses fd 3 for the controlling terminal. /bin/sh opens /dev/tty and stores the resulting file descriptor in ttyfd: jobs.c: 122: if (on) { 123: if (ttyfd != -1) 124: close(ttyfd); 125: if ((ttyfd = open(_PATH_TTY, O_RDWR)) < 0) { 126: i = 0; 127: while (i <= 2 && !isatty(i)) 128: i++; 129: if (i > 2 || (ttyfd = dup(i)) < 0) 130: goto out; 131: } ttyfd is needed for calls to tcsetpgrp. To prevent conflicts with user-fd, ttyfd should be moved to a higher fd like bash2 does: jobs.c: 2911: /* Get our controlling terminal. If job_control is set, or 2912: interactive is set, then this is an interactive shell no 2913: matter where fd 2 is directed. */ 2914: shell_tty = dup (fileno (stderr)); /* fd 2 */ 2915: 2916: shell_tty = move_to_high_fd (shell_tty, 1, -1); 2917: I would try to fix this, could someone please tell me, if this is the right way... Friedemann To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message