I have the following line in my inetd.conf:
telnet stream tcp4 nowait nobody /usr/sbin/in.telnetd in.telnetd -hL /etc/rc.telnet
If /etc/rc.telnet contains this:
#!/bin/sh
echo hi
And I telnet to the machine, I get "hi" as output and the connection stays
open, with in.telnetd using a lot of cpu time and having a zombie child
(rc.telnet).
Strace shows it is calling select and read in a tight loop:
select(4, [0 3], [], [0], NULL) = 1 (in [3])
read(3, 0x60b5e0, 8192) = -1 EIO (Input/output error)
select(4, [0 3], [], [0], NULL) = 1 (in [3])
read(3, 0x60b5e0, 8192) = -1 EIO (Input/output error)
select(4, [0 3], [], [0], NULL) = 1 (in [3])
read(3, 0x60b5e0, 8192) = -1 EIO (Input/output error)
select(4, [0 3], [], [0], NULL) = 1 (in [3])
read(3, 0x60b5e0, 8192) = -1 EIO (Input/output error)
If I add a "sleep 1" to rc.telnet, then the connection is closed properly,
so there seems to be a race condition somewhere.