Re: Out of ptys

Matthias Urlichs (smurf@noris.de)
25 Aug 1998 07:50:31 +0200


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.

-- 
Matthias Urlichs
noris network GmbH

- 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