On Fri, Jun 23, 2006 at 02:54:04PM +1200, John Carter wrote: > > Here is the bash-3.1 code from general.c for check_dev_tty. > > It is invoked shortly after main... > > void > check_dev_tty () > { > int tty_fd; > char *tty; > > tty_fd = open ("/dev/tty", O_RDWR|O_NONBLOCK); > > if (tty_fd < 0) > { > tty = (char *)ttyname (fileno (stdin)); > if (tty == 0) > return; > tty_fd = open (tty, O_RDWR|O_NONBLOCK); > } > close (tty_fd); > } > > It seems to open and close /dev/tty and return nothing. > > This seems very strange to me. > > Why is it doing this? [...]
A rough guess: It may be that, if bash is the session leader and no session is attached to the terminal open on stdin, the open would attach the terminal to the session. Bash would become the controlling process. I guess it might happen when you boot Linux with init=/bin/bash for instance. It may not be the reason for it, though. And I'm not sure it is right for bash to do so. -- Stephane _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash