Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jan 2003 18:00:31 +0100 (CET)
From:      Friedemann Becker <lucius@infos.com>
To:        freebsd-bugs@freebsd.org
Subject:   Re: bin/47136:
Message-ID:  <20030126173949.D1679@chasey.wg>

index | next in thread | raw e-mail

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



help

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