bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

check_dev_tty - What does it do?


From: John Carter
Subject: check_dev_tty - What does it do?
Date: Fri, 23 Jun 2006 14:54:04 +1200 (NZST)


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?



John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : address@hidden
New Zealand

Carter's Clarification of Murphy's Law.

"Things only ever go right so that they may go more spectacularly wrong later."

From this principle, all of life and physics may be deduced.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]