lkml.org 
[lkml]   [1998]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: Out of ptys
Hi,

Richard B. Johnson:
> > >
> > 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".

Which is, in this case, because the answer is exactly that -- wrong.
Sorry about that...

> 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.
>
When telnetd (or anything else, for that matter) is exec()d by inetd, fds 1
and 2 are definitely NOT closed. For proof, just let inetd execute "/bin/ls
-l /proc/self/fd" or whatever, and telnet to localhost. Output:
total 0
lrwx------ 1 root pop 64 Aug 25 16:05 0 -> socket:[174614]
lrwx------ 1 root pop 64 Aug 25 16:05 1 -> socket:[174614]
lrwx------ 1 root pop 64 Aug 25 16:05 2 -> socket:[174614]
lr-x------ 1 root pop 64 Aug 25 16:05 3 -> /proc/13042/fd

There are lots of legacy programs which close fds 0 to 2 and then expect
that the next three open() calls will fill these slots. Just look at the
appropriate place in the kernel. The cited "unexpected behavior" just
isn't possible.

The ioctls failed because a TCP socket isn't a tty, not because the file
descriptor was closed. Proof: The ioctl calls returned EINVAL and not EBADF.
--
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

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.093 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site