handle keyboard interrupt in recv function