00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "defs.h"
00022
00023 static void handler(int signum)
00024 {
00025 }
00026
00027 int main(void)
00028 {
00029 struct sigaction act;
00030 char buf[100];
00031 ssize_t rtn;
00032
00033 memset(&act, 0, sizeof(act));
00034 act.sa_handler = handler;
00035 ec_neg1( sigaction(SIGALRM, &act, NULL) )
00036 alarm(5);
00037 if ((rtn = read(STDIN_FILENO, buf, sizeof(buf) - 1)) == -1) {
00038 if (errno == EINTR)
00039 printf("Timed out... type faster next time!\n");
00040 else
00041 EC_FAIL
00042 }
00043 alarm(0);
00044 if (rtn == 0)
00045 printf("Got EOF\n");
00046 else if (rtn > 0) {
00047 buf[rtn] = '\0';
00048 printf("Got %s", buf);
00049 }
00050 exit(EXIT_SUCCESS);
00051
00052 EC_CLEANUP_BGN
00053 exit(EXIT_FAILURE);
00054 EC_CLEANUP_END
00055 }