设置定时器(timer), 捕捉SIGALRM信号

    1. void handler(int signo){return;}
    2. struct sigaction act;
    3. sigaction(SIGALRM, NULL, &act);
    4. act.sa_handler = handler;
    5. act.sa_flags &= ~SA_RESTART;//清除掉SIGALRM信号的SA_RESTART
    6. sigaction(SIGALRM, &act, NULL);
    7. alarm(5);
    8. if (recv(,,,) < 0) ……