When a client closes its connection or gets disconnected select() will report it as being readable. However when you actually read from it sysread will return zero. You should check the result of sysread for this condition and close the connection, but you do not. Because you do not, the select() will continue to report the handle as readable and so you have a loop that never sleeps