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 10:00
Create a word problem that involves calculating the volume and surface area of a three-dimensional object. cube: surface area 6 s2 , volume s3
Answers: 3
question
Computers and Technology, 22.06.2019 14:30
What percentage of companies is projected to use social media to locate new employees in 2012
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a.if the manual switch s is on, then the light l is on. b.besides the manual switch, there is a motion detector, m1, which activatesthis light.c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d.the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Best laptops for college [$100-$500 range]?
Answers: 2
You know the right answer?
Design and implement a simple shell program (in C programming language) to set a timer to terminate...
Questions
question
Mathematics, 08.01.2021 20:10
question
Mathematics, 08.01.2021 20:10
question
Arts, 08.01.2021 20:10
question
Mathematics, 08.01.2021 20:10
question
Mathematics, 08.01.2021 20:10
Questions on the website: 13722360