From: Daniel Berger Date: 2007-08-06T23:19:07+09:00 Subject: Re: Bug in Ruby's PTY extension On Aug 5, 11:28 am, "ronald braswell" wrote: > I'm new to the ML so please forgive me if this has been discussed > previously. > > Ruby version: 1.8.5 > OS: Solaris 10 x64 (11/06) > CPU: Dual core Opteron > > When using expect or RExpect I was getting an intermittent premature > EOFError on the first call to expect. Catching this exception and then > going on was an ugly work around. > > pty.c: > > I noticed that Solaris 10 does not support TIOCSCTTY so in function > establishShell() the child process closes the slave device and reopens it to > force it to be the controlling tty. The parent process also closes the > slave device because it does not need it. I added a call to nanosleep for > 20 milliseconds just before the parent process closes the slave fd at the > end of establishShell() and I now both expect and RExpect work reliably. I > suspect that just keeping a reference to the open file object in the parent > process while the child process closes and reopens the slave device prevents > the EOF from occurring -- but I am far from an expert on Solaris internals. > This may not be the best way to solve the problem and just adding the small > delay does not ensure that the problem will never happen again but so far, > so good. This quote from comp.programming may be useful: "In System V, the controlling terminal is the first tty that's opened that is not already associated with a session. If you don't want that tty to be the controlling terminal, use the O_NOCTTY flag on open(). You don't need the TIOCSCTTY ioctl in SVR4 systems." http://tinyurl.com/2af8ob Regards, Dan