<div>Hi.</div><div> </div><div>My real situation is like this : </div><div>1. running telnetd on embedded board.</div><div>2. running client on windows/linux </div><div>3. client works something on connection such as getting big file with tftp or testing system with automated script for a long time. </div><div>4. client is killed abnormally, for example kill telnet process</div><div>5. At this time, telnetd goes infinite loop and cpu occupation almost becomes 90%.</div><div> </div><div>I think this connection should be closed completely and telnetd should hold for next connection using select().</div><div>but select() returns 1, and it means a socket fd has some changes.</div><div>That is telnetd does not catch client already killed.</div><div> </div><div>(Unfortunatly, PC running telnetd can't reproduce this issue. I recommended to check any embedded board if you have)</div><div> </div><div>As I know, It is abnormally disconnected network and should handle.</div><div>The only ambigous thing in the patch is the max fail count.</div><div>At first, set max fail count as 10, but it is not standard I think.</div><div> </div><div>Thanks.</div><div>  </div><div> </div><div>------------------------------------------------------------------------------------------------</div><div>Message: 5<br> Date: Tue, 17 Mar 2015 09:59:18 -0400<br> From: Rich Felker <<a href="mailto:dalias@libc.org">dalias@libc.org</a>><br> To: <a href="mailto:toybox@lists.landley.net">toybox@lists.landley.net</a><br> Subject: Re: [Toybox] PATCH telnetd<br> Message-ID: <<a href="mailto:20150317135918.GY23507@brightrain.aerifal.cx">20150317135918.GY23507@brightrain.aerifal.cx</a>><br> Content-Type: text/plain; charset=utf-8<br><br> On Tue, Mar 17, 2015 at 07:31:12PM +0900, ??? wrote:<br>> Hi. All<br>> <br>> I found an issue of telnetd that it loops infinitely when client<br>> disconnected abnormally on working.<br>> like client is killed by outside.<br>> <br>> On embedded system, this issue make that cpu occupation goes high.<br>> <br>> In this case :<br>> select() returns 1, means socket fd has something changes.<br>> but, read()/write() after select() gets an error because client already<br>> disconnected.<br><br> read does not return an error; it returns 0, indicating EOF.<br><br>> attached patch help prevent this issue.<br>> plz, check.<br><br> The patch as written does not seem correct. There is no justification<br> for killing the child process with SIGKILL; this is a very bad<br> practice and precludes any sort of cleanup it may need to do. Unless<br> it's specifically written not to, the child running in the telnet<br> session should automatically terminate when it loses its controlling<br> terminal, which should happen when the telnet session exits.<br><br> Can you clarify what exactly is going wrong for you?<br><br> Rich<br></div>