# HG changeset patch # User Karoly Lorentey # Date 1086655573 0 # Node ID ae72b7a6c292de09e97105ea7daf2930b79d84f8 # Parent 8a11bf743e667a82f43a5cb30f85b0fb24e8d799 Dissociate from the controlling tty correctly on FreeBSD. * src/term.c (dissociate_if_controlling_tty): On some systems TIOCNOTTY works only on /dev/tty. Adapt the function accordingly. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-194 diff -r 8a11bf743e66 -r ae72b7a6c292 src/term.c --- a/src/term.c Tue Jun 08 00:41:04 2004 +0000 +++ b/src/term.c Tue Jun 08 00:46:13 2004 +0000 @@ -2256,26 +2256,29 @@ void dissociate_if_controlling_tty (int fd) { -#if defined (USG) && !defined (BSD_PGRPS) int pgid; - EMACS_GET_TTY_PGRP (fd, &pgid); + EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */ if (pgid != -1) { +#if defined (USG) && !defined (BSD_PGRPS) setpgrp (); no_controlling_tty = 1; - } #else #ifdef TIOCNOTTY /* Try BSD ioctls. */ - sigblock (sigmask (SIGTTOU)); - if (ioctl (fd, TIOCNOTTY, 0) != -1) - { - no_controlling_tty = 1; + sigblock (sigmask (SIGTTOU)); + fd = emacs_open ("/dev/tty", O_RDWR, 0); + if (fd != -1 && ioctl (fd, TIOCNOTTY, 0) != -1) + { + no_controlling_tty = 1; + } + if (fd != -1) + emacs_close (fd); + sigunblock (sigmask (SIGTTOU)); +#else + /* Unknown system. */ + croak (); +#endif /* ! TIOCNOTTY */ } - sigunblock (sigmask (SIGTTOU)); -#else - /* Unknown system. */ - croak (); -#endif /* ! TIOCNOTTY */ #endif /* ! USG */ }