Ash + telnetd: telnet client hangs after exit
Denys Vlasenko
vda.linux at googlemail.com
Mon Oct 15 13:55:54 PDT 2007
On Monday 15 October 2007 17:03, Ralf Friedl wrote:
> Denys Vlasenko wrote:
> > On Monday 15 October 2007 15:15, Alexander Kriegisch wrote:
> >
> >> BTW, the output "ps" output diff looks like this on i386:
> >>
> >> $ diff -U0 ps1.txt ps2.txt
> >> --- ps1.txt 2007-10-15 16:13:06.000000000 +0200
> >> +++ ps2.txt 2007-10-15 16:13:25.000000000 +0200
> >> @@ -130 +129,0 @@
> >> -root 31704 31643 0 16:10 ? 00:00:00 [login] <defunct>
> >>
> >
> > Aha. You have a login which does not exec shell, it spawns it
> > as a child. When shell exits, login exits too.
> >
> > What looks strange to me is that you see a _zombie_ login.
> > It means that it exited, but is not waited for yet.
> >
> > How come telnetd doesn't see EOF from login's fd? It *exited*,
> > and that implicitly closes all fds! I'm puzzled.
> >
> telnetd doesn't see EOF on the pty side because the client pty is open
> by a child of the shell, not the shell itself.
You mean that Alexander missed another process which keeps open fd
and is still alive. Yes, that explains things.
> The reason why the process is a zombie is that telnetd will only wait
> for the child after sending SIGKILL, and it will only send SIGKILL after
> either the network connection or the client side of the pty is closed.
> But in this case the problem is that the client pty is not closed.
...
> The only change in your patch which seems relevant to this problem is
> where you removed the SIGKILL before the wait(). I think this is
> dangerous in a single-threaded server. The child shell will probably
> eventually clean up and exit, but if that takes some seconds, all other
> connections will hang for that time.
No, I not only removed SIGKILL, I also removed wait:
/*kill(ts->shell_pid, SIGKILL);
wait4(ts->shell_pid, NULL, 0, NULL);*/
I don't wait for anything now. I tear down connections as soon
as there is a problem (or EOF) reading/writing to the pty.
Ralf, can you review attached patch?
Alexander, can you try it?
It adds -K option, with which telnetd close sessions as soon as it
sees login exiting (se help text).
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 7a.diff
Type: text/x-diff
Size: 21030 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20071015/cd431875/attachment.bin
More information about the busybox
mailing list