Re: Out of ptys

Richard B. Johnson (root@chaos.analogic.com)
Tue, 25 Aug 1998 09:14:01 -0400 (EDT)


On 25 Aug 1998, Matthias Urlichs wrote:

> root@chaos.analogic.com writes:
> >
> > > > open("/dev/ptyp2", O_RDWR) = 3
> > > > ioctl(1, TCGETS, 0xbffff1dc) = -1 EINVAL (Invalid argument)
> > > > ioctl(2, TCGETS, 0xbffff1d0) = -1 EINVAL (Invalid argument)
> > > >
> > > No, they are invalid because you don't have a stdout and stderr.
> > > open() doesn't work the way you seem to think here.
> >
> > Well there was never a dup() of any kind, so there could not be a fd
> > for stdout or stderr. I can see from the source that the idea was
> > to open these devices until one could be found that did not fail.
> >
> Wrong. open() _always_ returns the first free fd. If it returns 3, then
> 0..2 are open, possibly to /dev/null or whatever. Most likely, your program
> inherited them that way from the parent process.

Don't you love the way these replies start! Always with "wrong" or "no".
The "program" to which you refer is telnetd. The ioctls failed because
there were no open fds 1 or 2, yet an open returned 3. Telnetd failed
because this was unexpected behavior.

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.1.115 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html