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 19:30
Can you make money in why are you guys so
Answers: 1
question
Computers and Technology, 22.06.2019 17:20
[a] create a class called “cycle” which has two instance integer variables as properties, “numberofwheels” and “weight.” create a constructor with two parameters, using the same variable names in the parameter list. assign each variable to numberofwheels” and “weight” respectively. write a separate application to test the class and display its properties. note: do not change the names of the instance variables or the variables listed in the constructor’s parameter list. [b] edit your class cycle by adding a default constructor which will assign the default values of 100 to represent the numberofwheels, and 1000 to represent the weight, by invoking a call to the other constructor. modify your application created in [a] to test the class.
Answers: 3
question
Computers and Technology, 23.06.2019 01:20
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
question
Computers and Technology, 23.06.2019 07:30
What is the penalty for violating section 1201 of title 17 chapter 21 of the us code
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
Mathematics, 26.03.2021 19:20
question
History, 26.03.2021 19:20
question
Mathematics, 26.03.2021 19:20
question
Mathematics, 26.03.2021 19:20