subject

Design and implement a simple shell program (in C programming language) to set a timer to terminate the program after one minute being idle. That is, if there is no command input within one minute after the prompt, then the program will be interrupted by the timer and the timer-handler will terminate the program. Further the program should take an input command to set a timer interval. The following command will set the timer for 30 seconds: timer=30When the program got the timer interrupt (for example, after 30 seconds of idle time), it prints the message saying: "the program is terminated due to the idle time over 30 seconds."A sample code to set a timer for 30 seconds:// Sample code to set a timer to interrupt after some time (to terminate the run). #include #include #include #include #include static int timer_expired = 0; static void alarm_handler(int sig) { timer_expired=30; } int main() { // Set up a signal hander to call alarm_handler() // when SIGALRM is raised sigaction(SIGALRM, &(struct sigaction){.sa_handler = alarm_handler}, NULL); time_t t; srand((unsigned) time(&t)); timer_expired = 0; alarm(1); // raise SIGALRM in 1 seconds while (!timer_expired) { int s=(rand()%4)+1; printf("%d", s); } return 0;

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:20
Find the inverse function of f(x)= 1+squareroot of 1+2x
Answers: 2
question
Computers and Technology, 22.06.2019 10:00
You need a reliable network for about twenty-five computers that will be distributed across a large building. it is important that the network be relatively cheap. which topology should you use?
Answers: 1
question
Computers and Technology, 22.06.2019 12:40
The most complicated four letter word
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
The output voltage of a power supply is assumed to be normally distributed. sixteen observations are taken at random on voltage are as follows: 10.35, 9.30, 10.00, 9.96, 11.65, 12.00, 11.25, 9.58, 11.54, 9.95, 10.28, 8.37, 10.44, 9.25, 9.38, and 10.85
Answers: 1
You know the right answer?
Design and implement a simple shell program (in C programming language) to set a timer to terminate...
Questions
question
English, 17.11.2019 00:31
Questions on the website: 13722362