From: Guy R. <gu...@cw...> - 2002-05-28 10:19:01
|
Hi, =20 I am running into a few problems with Expect-1.15 on perl5.005. = Specifically, I get "Error: could not connect pty as controlling = terminal!" from time to time when trying to spawn a telnet to another = machine. I'm using FreeBSD 4.3 on i586. As far as I can tell from digging a little in the Pty/Expect/Tty code as = well as the kernel code, there's a problem with getting rid of = controlling terminals on FreeBSD. Actually the sentence "Implement = TIOCNOTTY or remove it from <sys/ioctl.h>" appears in the todo list in = /src/sys/kern/tty.c on FreeBSD. The problem as I can see it is in the following scenario: 1. in Expect->new, a pty is assigned 2. in spawn, Pty->make_slave_controlling_terminal is called 3. there it performs setsid() 4. afterwards it checks for the member {'io_pty_slave'} which was = generated before, in the context of the previous session, and therefor = the session struct in the kernel holds data about the previous session's = controlling terminal 5. the call for TIOCSCTTY has the following code in it (tty.c): if (!SESS_LEADER(p) || ((p->p_session->s_ttyvp || tp->t_session) && (tp->t_session !=3D p->p_session))) return (EPERM); where p is the proc structure, and tp is the tty structure (pointers = ofcourse) =20 Remembering that setsid() creates a new session context for the process = and that tp might have had a controlling tty associated with it, = problems may occur. Btw, as I mentioned earlier TIOCNOTTY has not yet been implemented. =20 I'm pretty sure that I haven't reached a full understanding in all of = this, so any corrections would be very welcome. =20 Guy |