Ash + telnetd: telnet client hangs after exit

Denys Vlasenko vda.linux at googlemail.com
Mon Nov 5 07:31:57 PST 2007


On Monday 05 November 2007 11:55, Ralf Friedl wrote:
> Hi
> 
> I found some more problems with the current telnetd code (I'm sorry that 
> I didn't notice them earlier).
> 
> The bigger problem is that without the option -K, telnetd will never 
> wait for its children, leaving them as zombies.
> 
> A minor problem is that it is possible, although unlikely, that two 
> children exit at the same time. Or more exactly, it is possible that one 
> child exits, which raises SIGCHLD for telnetd. If another child exits 
> after the first, but before the signal was delivered, the signal handler 
> will be called only once, not twice for the two children.
> If the system is heavy loaded, maybe parts of telnetd paged out, this 
> time may be log enough for this to happen.
> It is unlikely to happen with telnetd, but I already had this problem 
> with a mail server in real life. The solution is to loop in the signal 
> handler until wait finds no more children.
> 
> I also changed the argument to waitpid from &sig to NULL because "man 
> waitpid" says: "If status is not NULL, wait or waitpid store ...", 
> because the status is not used.

Thanks for the patch. Please review attached version.

I noticed another bug: we do not restore SIGCHLD/SIGPIPE to default.

As to "zombies created without -K" problem, I guess
        signal(SIGCHLD, SIG_IGN);
will prevent that, no need to have handler installed/called.
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.patch
Type: text/x-diff
Size: 3639 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20071105/52dd0d19/attachment.bin 


More information about the busybox mailing list