use SIG_ALRM to handle read&write timeout