github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/tests/sys_time.c (about) 1 #include <assert.h> 2 #include <signal.h> 3 #include <stdio.h> 4 #include <sys/time.h> 5 #include <unistd.h> 6 7 #include "tests.h" 8 9 void handler(int signo) 10 { 11 static const char msg[] = "\n*** Timer expired, you lose ***\n"; 12 assert(signo == SIGALRM); 13 write(2, msg, sizeof(msg) - 1); 14 exit(1); 15 } 16 17 int main(void) 18 { 19 plan(0);// 1); 20 // TODO: commented for github action 21 22 // struct itimerval tval; 23 // char string[BUFSIZ]; 24 25 // timerclear(&tval.it_interval); /* zero interval means no reset of timer */ 26 // timerclear(&tval.it_value); 27 28 // tval.it_value.tv_sec = 10; /* 10 second timeout */ 29 30 // (void)signal(SIGALRM, handler); 31 32 // printf("You have ten seconds to enter\nyour name, rank, and serial number: "); 33 34 // (void)setitimer(ITIMER_REAL, &tval, NULL); 35 // if (fgets(string, sizeof string, stdin) != NULL) { 36 // (void)setitimer(ITIMER_REAL, NULL, NULL); /* turn off timer */ 37 // /* process rest of data, diagnostic print for illustration */ 38 // printf("I'm glad you are being cooperative.\n"); 39 // pass("ok"); 40 // } else 41 // printf("\nEOF, eh? We won't give up so easily!\n"); 42 43 done_testing(); 44 }