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, 22.06.2019 09:40
It is vital to research each of the services you plan to disable before implementing any change, especially on critical machines such as the: a. servers in the test environment. b. domain controller and other infrastructure servers. c. desktops that have previously been attacked. d. desktops used by upper-level management.
Answers: 2
question
Computers and Technology, 23.06.2019 08:30
All of these are true about using adhesive except: a. dissimilar materials can be joined. b. mixing tips are product and material specific. c. a specific application gun may be required. d. two-part adhesives are dispensed using two mixing tips
Answers: 3
question
Computers and Technology, 23.06.2019 13:50
Explain how email technologies enable the exchange of messages between users. find out the typical parts of an email address and explain each part.
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Consider the series where in this problem you must attempt to use the ratio test to decide whether the series converges. compute enter the numerical value of the limit l if it converges, inf if it diverges to infinity, minf if it diverges to negative infinity, or div if it diverges but not to infinity or negative infinity.
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, 26.05.2021 14:00
question
Mathematics, 26.05.2021 14:00
question
Mathematics, 26.05.2021 14:00
question
English, 26.05.2021 14:00
question
Mathematics, 26.05.2021 14:00
question
Chemistry, 26.05.2021 14:00
question
Mathematics, 26.05.2021 14:00
question
Mathematics, 26.05.2021 14:00
Questions on the website: 13722360