Your program should create a counter variable. Counting details in part 1. When the programfinally completes, the program should output the number of times the user depressed CTRL-C.(1) The first is to handle the SIGINT (CTRL-C, ^C) signal. This signal handler should incrementthe counter.The signal handler should also contain a MAX value (say 5) that is used. In the case thatthe maximum is reached:• a message indicating that the MAX has been exceeded should be output• the signal handler should be "deactivated" so that the next instance of the ^Csignal causes the program to terminate.(2) The second signal handler should deal with the SIGQUIT signal (CTRL-\, ^\). If the usersends this signal, the signal handler should create a new process (fork).This child process should print a message and then send a SIGUSR1 signal (using kill())to its parent. The child should terminate with no error code. This must be accomplishedwithout using any of the exec() family of calls.The parent side of the fork() should just exit the signal handler without doing anything.(3) The final signal handler (for the parent) should catch the SIGUSR1 signal (sent by the childprocess in part 2). This handler should print a message that the program is over and then exit.The parent should simply wait for the child to terminate, then exit gracefully.The main program should contain a loop forever waiting for a signal (i.e. pause).
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Your
finally completes, the program should output the number of times the user depressed CTRL-C.
(1) The first is to handle the SIGINT (CTRL-C, ^C) signal. This signal handler should increment
the counter.
The signal handler should also contain a MAX value (say 5) that is used. In the case that
the maximum is reached:
• a message indicating that the MAX has been exceeded should be output
• the signal handler should be "deactivated" so that the next instance of the ^C
signal causes the program to terminate.
(2) The second signal handler should deal with the SIGQUIT signal (CTRL-\, ^\). If the user
sends this signal, the signal handler should create a new process (fork).
This child process should print a message and then send a SIGUSR1 signal (using kill())
to its parent. The child should terminate with no error code. This must be accomplished
without using any of the exec() family of calls.
The parent side of the fork() should just exit the signal handler without doing anything.
(3) The final signal handler (for the parent) should catch the SIGUSR1 signal (sent by the child
process in part 2). This handler should print a message that the program is over and then exit.
The parent should simply wait for the child to terminate, then exit gracefully.
The main program should contain a loop forever waiting for a signal (i.e. pause).
Unlock instant AI solutions
Tap the button
to generate a solution